mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-06-12 18:54:46 +02:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| af1c845d09 | |||
| 59e09d1672 | |||
| aee36057b6 | |||
| 8eb85bc81c | |||
| 3510bad641 | |||
| a26180b5d1 | |||
| 8f6b70b260 | |||
| 342eb1bf7e | |||
| 2f876f353f | |||
| 780655c886 | |||
| 6a81fc54aa | |||
| 5ff71d369d | |||
| 0234dfeae6 | |||
| fed77b386d | |||
| ec1fa23dad | |||
| 0f4443efd0 | |||
| f31b959ff5 | |||
| 97bd2d7a48 | |||
| 329639f9f1 |
+2
-2
@@ -34,11 +34,11 @@ FROMDOS=/home/cmunk/bin/4dos
|
||||
#
|
||||
|
||||
#XCFLAGS=-O -g -export-dynamic
|
||||
IRCDLIBS=@IRCDLIBS@ @TRELIBS@
|
||||
IRCDLIBS=@IRCDLIBS@ @TRELIBS@ @CARESLIBS@
|
||||
CRYPTOLIB=@CRYPTOLIB@
|
||||
OPENSSLINCLUDES=
|
||||
|
||||
XCFLAGS=-I@TREINCDIR@ @CFLAGS@
|
||||
XCFLAGS=-I@TREINCDIR@ -I@CARESINCDIR@ @CFLAGS@
|
||||
#
|
||||
# use the following on MIPS:
|
||||
#CFLAGS= -systype bsd43 -DSYSTYPE_BSD43 -I$(INCLUDEDIR)
|
||||
|
||||
+35
-4
@@ -425,7 +425,7 @@ IRCDLIBS="$IRCDLIBS -lresolv "
|
||||
;;
|
||||
esac
|
||||
|
||||
dnl REMEMBER TO CHANGE WITH A NEW RELEASE!
|
||||
dnl REMEMBER TO CHANGE WITH A NEW TRE RELEASE!
|
||||
tre_version="0.7.2"
|
||||
AC_MSG_RESULT(extracting TRE regex library)
|
||||
cur_dir=`pwd`
|
||||
@@ -442,11 +442,11 @@ else
|
||||
fi
|
||||
AC_MSG_RESULT(configuring TRE regex library)
|
||||
cd tre-$tre_version
|
||||
./configure --disable-agrep --disable-shared --disable-system-abi --disable-wchar --disable-multibyte --prefix=$cur_dir/extras/regexp
|
||||
./configure --disable-agrep --disable-shared --disable-system-abi --disable-wchar --disable-multibyte --prefix=$cur_dir/extras/regexp || exit 1
|
||||
AC_MSG_RESULT(compiling TRE regex library)
|
||||
$ac_cv_prog_MAKER
|
||||
$ac_cv_prog_MAKER || exit 1
|
||||
AC_MSG_RESULT(installing TRE regex library)
|
||||
$ac_cv_prog_MAKER install
|
||||
$ac_cv_prog_MAKER install || exit 1
|
||||
TREINCDIR="$cur_dir/extras/regexp/include"
|
||||
AC_SUBST(TREINCDIR)
|
||||
if test "x$ac_cv_path_PKGCONFIG" = "x" ; then
|
||||
@@ -456,6 +456,37 @@ else
|
||||
fi
|
||||
AC_SUBST(TRELIBS)
|
||||
cd $cur_dir
|
||||
|
||||
|
||||
dnl REMEMBER TO CHANGE WITH A NEW C-ARES RELEASE!
|
||||
cares_version="1.3.0"
|
||||
AC_MSG_RESULT(extracting c-ares resolver library)
|
||||
cur_dir=`pwd`
|
||||
cd extras
|
||||
dnl remove old c-ares directory to force a recompile...
|
||||
rm -rf c-ares-$cares_version
|
||||
if test "x$ac_cv_path_GUNZIP" = "x" ; then
|
||||
tar xfz c-ares.tar.gz
|
||||
else
|
||||
cp c-ares.tar.gz c-ares.tar.gz.bak
|
||||
gunzip -f c-ares.tar.gz
|
||||
cp c-ares.tar.gz.bak c-ares.tar.gz
|
||||
tar xf c-ares.tar
|
||||
fi
|
||||
AC_MSG_RESULT(configuring c-ares library)
|
||||
cd c-ares-$cares_version
|
||||
./configure --prefix=$cur_dir/extras/c-ares || exit 1
|
||||
AC_MSG_RESULT(compiling c-ares resolver library)
|
||||
$ac_cv_prog_MAKER || exit 1
|
||||
AC_MSG_RESULT(installing c-ares resolver library)
|
||||
$ac_cv_prog_MAKER install || exit 1
|
||||
CARESINCDIR="$cur_dir/extras/c-ares/include"
|
||||
AC_SUBST(CARESINCDIR)
|
||||
CARESLIBS="-L../extras/c-ares/lib -lcares"
|
||||
AC_SUBST(CARESLIBS)
|
||||
cd $cur_dir
|
||||
|
||||
|
||||
AC_OUTPUT(Makefile src/modules/Makefile unreal ircdcron/ircdchk)
|
||||
chmod 0700 unreal
|
||||
chmod 0700 ircdcron/ircdchk
|
||||
|
||||
@@ -10560,8 +10560,7 @@ cat >>confdefs.h <<\_ACEOF
|
||||
#define INET6 1
|
||||
_ACEOF
|
||||
|
||||
have_v6="yes"
|
||||
echo "$as_me:$LINENO: checking for struct in6addr_any" >&5
|
||||
echo "$as_me:$LINENO: checking for struct in6addr_any" >&5
|
||||
echo $ECHO_N "checking for struct in6addr_any... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
#line $LINENO "configure"
|
||||
@@ -10694,13 +10693,13 @@ fi
|
||||
echo "$as_me:$LINENO: result: configuring TRE regex library" >&5
|
||||
echo "${ECHO_T}configuring TRE regex library" >&6
|
||||
cd tre-$tre_version
|
||||
./configure --disable-agrep --disable-shared --disable-system-abi --disable-wchar --disable-multibyte --prefix=$cur_dir/extras/regexp
|
||||
./configure --disable-agrep --disable-shared --disable-system-abi --disable-wchar --disable-multibyte --prefix=$cur_dir/extras/regexp || exit 1
|
||||
echo "$as_me:$LINENO: result: compiling TRE regex library" >&5
|
||||
echo "${ECHO_T}compiling TRE regex library" >&6
|
||||
$ac_cv_prog_MAKER
|
||||
$ac_cv_prog_MAKER || exit 1
|
||||
echo "$as_me:$LINENO: result: installing TRE regex library" >&5
|
||||
echo "${ECHO_T}installing TRE regex library" >&6
|
||||
$ac_cv_prog_MAKER install
|
||||
$ac_cv_prog_MAKER install || exit 1
|
||||
TREINCDIR="$cur_dir/extras/regexp/include"
|
||||
|
||||
if test "x$ac_cv_path_PKGCONFIG" = "x" ; then
|
||||
@@ -10710,6 +10709,39 @@ else
|
||||
fi
|
||||
|
||||
cd $cur_dir
|
||||
|
||||
|
||||
cares_version="1.3.0"
|
||||
echo "$as_me:$LINENO: result: extracting c-ares resolver library" >&5
|
||||
echo "${ECHO_T}extracting c-ares resolver library" >&6
|
||||
cur_dir=`pwd`
|
||||
cd extras
|
||||
rm -rf c-ares-$cares_version
|
||||
if test "x$ac_cv_path_GUNZIP" = "x" ; then
|
||||
tar xfz c-ares.tar.gz
|
||||
else
|
||||
cp c-ares.tar.gz c-ares.tar.gz.bak
|
||||
gunzip -f c-ares.tar.gz
|
||||
cp c-ares.tar.gz.bak c-ares.tar.gz
|
||||
tar xf c-ares.tar
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: configuring c-ares library" >&5
|
||||
echo "${ECHO_T}configuring c-ares library" >&6
|
||||
cd c-ares-$cares_version
|
||||
./configure --prefix=$cur_dir/extras/c-ares || exit 1
|
||||
echo "$as_me:$LINENO: result: compiling c-ares resolver library" >&5
|
||||
echo "${ECHO_T}compiling c-ares resolver library" >&6
|
||||
$ac_cv_prog_MAKER || exit 1
|
||||
echo "$as_me:$LINENO: result: installing c-ares resolver library" >&5
|
||||
echo "${ECHO_T}installing c-ares resolver library" >&6
|
||||
$ac_cv_prog_MAKER install || exit 1
|
||||
CARESINCDIR="$cur_dir/extras/c-ares/include"
|
||||
|
||||
CARESLIBS="-L../extras/c-ares/lib -lcares"
|
||||
|
||||
cd $cur_dir
|
||||
|
||||
|
||||
ac_config_files="$ac_config_files Makefile src/modules/Makefile unreal ircdcron/ircdchk"
|
||||
cat >confcache <<\_ACEOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
@@ -11297,6 +11329,8 @@ s,@BINDIR@,$BINDIR,;t t
|
||||
s,@FD_SETSIZE@,$FD_SETSIZE,;t t
|
||||
s,@TREINCDIR@,$TREINCDIR,;t t
|
||||
s,@TRELIBS@,$TRELIBS,;t t
|
||||
s,@CARESINCDIR@,$CARESINCDIR,;t t
|
||||
s,@CARESLIBS@,$CARESLIBS,;t t
|
||||
CEOF
|
||||
|
||||
_ACEOF
|
||||
|
||||
Binary file not shown.
+8
-1
@@ -385,7 +385,7 @@ extern struct hostent *get_res(char *);
|
||||
extern struct hostent *gethost_byaddr(char *, Link *);
|
||||
extern struct hostent *gethost_byname(char *, Link *);
|
||||
extern void flush_cache();
|
||||
extern int init_resolver(int);
|
||||
extern void init_resolver(void);
|
||||
extern time_t timeout_query_list(time_t);
|
||||
extern time_t expire_cache(time_t);
|
||||
extern void del_queries(char *);
|
||||
@@ -761,3 +761,10 @@ extern void charsys_addallowed(char *s);
|
||||
extern void charsys_reset(void);
|
||||
extern MODVAR char langsinuse[4096];
|
||||
extern MODVAR aTKline *tklines[TKLISTLEN];
|
||||
extern int isipv6(struct IN_ADDR *addr);
|
||||
extern void inet4_to_inet6(const void *src_in, void *dst_in);
|
||||
extern void unrealdns_delreq_bycptr(aClient *cptr);
|
||||
extern void inet6_to_inet4(const void *src, void *dst);
|
||||
extern void sendtxtnumeric(aClient *to, char *pattern, ...);
|
||||
extern void unrealdns_gethostbyname_link(char *name, ConfigItem_link *conf);
|
||||
extern void unrealdns_delasyncconnects(void);
|
||||
|
||||
+74
-66
@@ -1,74 +1,82 @@
|
||||
/*
|
||||
* ircd/res_def.h (C)opyright 1992 Darren Reed.
|
||||
/* OMG... OMG! WHAT AN INCLUDE HORROR !!! */
|
||||
#undef strcasecmp
|
||||
#undef strncasecmp
|
||||
#ifdef WIN32
|
||||
#include <win32/ares/setup.h>
|
||||
#endif
|
||||
#include <ares.h>
|
||||
#include <ares_version.h>
|
||||
#undef strcasecmp
|
||||
#undef strncasecmp
|
||||
#ifndef GOT_STRCASECMP
|
||||
#define strcasecmp mycmp
|
||||
#define strncasecmp myncmp
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
DNSREQ_CLIENT = 1,
|
||||
DNSREQ_LINKCONF = 2,
|
||||
DNSREQ_CONNECT = 3
|
||||
} DNSReqType;
|
||||
|
||||
typedef struct _dnsreq DNSReq;
|
||||
|
||||
/* Depending on the request type, some fields are filled in:
|
||||
* cptr: DNSREQ_CLIENT, DNSREQ_CONNECT
|
||||
* link: DNSREQ_LINKCONF, DNSREQ_CONNECT
|
||||
*/
|
||||
|
||||
#define RES_INITLIST 1
|
||||
#define RES_CALLINIT 2
|
||||
#define RES_INITSOCK 4
|
||||
#define RES_INITDEBG 8
|
||||
#define RES_INITCACH 16
|
||||
|
||||
#define MAXPACKET 1024
|
||||
#define MAXALIASES 35
|
||||
#define MAXADDRS 35
|
||||
|
||||
#define AR_TTL 300 /* minimum TTL in seconds for dns cache entries */
|
||||
|
||||
struct hent {
|
||||
char *h_name; /* official name of host */
|
||||
char *h_aliases[MAXALIASES]; /* alias list */
|
||||
int h_addrtype; /* host address type */
|
||||
int h_length; /* length of address */
|
||||
/* list of addresses from name server */
|
||||
struct IN_ADDR h_addr_list[MAXADDRS];
|
||||
#define h_addr h_addr_list[0] /* address, for backward compatiblity */
|
||||
struct _dnsreq {
|
||||
DNSReq *prev, *next;
|
||||
char *name; /**< Name being resolved (only for DNSREQ_LINKCONF and DNSREQ_CONNECT) */
|
||||
char ipv6; /**< Resolving for ipv6 or ipv4? */
|
||||
DNSReqType type; /**< DNS Request type (DNSREQ_*) */
|
||||
aClient *cptr; /**< Client the request is for, NULL if client died OR unavailable */
|
||||
ConfigItem_link *linkblock; /**< Linkblock */
|
||||
};
|
||||
|
||||
typedef struct reslist {
|
||||
int id;
|
||||
int sent; /* number of requests sent */
|
||||
int srch;
|
||||
time_t ttl;
|
||||
char type;
|
||||
char retries; /* retry counter */
|
||||
char sends; /* number of sends (>1 means resent) */
|
||||
char resend; /* send flag. 0 == dont resend */
|
||||
time_t sentat;
|
||||
time_t timeout;
|
||||
struct IN_ADDR addr;
|
||||
char *name;
|
||||
struct reslist *next;
|
||||
Link cinfo;
|
||||
struct hent he;
|
||||
} ResRQ;
|
||||
typedef struct _dnscache DNSCache;
|
||||
|
||||
typedef struct cache {
|
||||
time_t expireat;
|
||||
time_t ttl;
|
||||
struct hostent he;
|
||||
struct cache *hname_next, *hnum_next, *list_next;
|
||||
} aCache;
|
||||
struct _dnscache {
|
||||
DNSCache *prev, *next; /**< Previous and next in linked list */
|
||||
DNSCache *hprev, *hnext; /**< Previous and next in hash list */
|
||||
char *name; /**< The hostname */
|
||||
struct IN_ADDR addr; /**< Stored IP address */
|
||||
time_t expires; /**< When record expires */
|
||||
};
|
||||
|
||||
typedef struct cachetable {
|
||||
aCache *num_list;
|
||||
aCache *name_list;
|
||||
} CacheTable;
|
||||
typedef struct _dnsstats DNSStats;
|
||||
|
||||
#define ARES_CACSIZE 101
|
||||
struct _dnsstats {
|
||||
unsigned int cache_hits;
|
||||
unsigned int cache_misses;
|
||||
unsigned int cache_adds;
|
||||
};
|
||||
|
||||
#define MAXCACHED 81
|
||||
#ifdef _WIN32
|
||||
typedef unsigned short u_int16_t;
|
||||
#endif
|
||||
extern struct __res_state ircd_res;
|
||||
extern int ircd_res_init();
|
||||
extern u_int ircd_res_randomid();
|
||||
extern u_int16_t ircd_getshort(const u_char *msgp);
|
||||
extern u_int32_t ircd_getlong(const u_char *msgp);
|
||||
extern void ircd__putshort(register u_int16_t s, register u_char *msgp);
|
||||
extern void ircd__putlong(register u_int32_t l,register u_char *msgp);
|
||||
extern int ircd_dn_expand(const u_char *msg, const u_char *eom, const u_char *src, char *dst, int dstsiz);
|
||||
extern int __ircd_dn_skipname(const u_char *ptr, const u_char *eom);
|
||||
extern int ircd_dn_comp(const char *src, u_char *dst, int dstsiz, u_char **dnptrs, u_char **lastdnptr);
|
||||
extern int ircd_res_mkquery(int op, const char *dname, int class, int type, const u_char *data,
|
||||
int datalen, const u_char *newrr_in, u_char *buf, int buflen);
|
||||
/** Time to keep cache records. */
|
||||
#define DNSCACHE_TTL 600
|
||||
|
||||
/** Size of the hash table (prime!).
|
||||
* Consumes <this>*4 on ia32 and <this>*4 on 64 bit
|
||||
* 241 seems a good bet.. which ~1k on ia32 and ~2k on ia64.
|
||||
*/
|
||||
#define DNS_HASH_SIZE 241
|
||||
|
||||
/** Max # of entries we want in our cache.
|
||||
* This:
|
||||
* a) prevents us from using too much memory, and
|
||||
* b) prevents us from keeping useless cache records
|
||||
*
|
||||
* A dnscache item is roughly ~80 bytes in size (slightly more on x86),
|
||||
* so 241*80=~20k, which seems reasonable ;).
|
||||
*/
|
||||
#define DNS_MAX_ENTRIES DNS_HASH_SIZE
|
||||
|
||||
|
||||
extern ares_channel resolver_channel;
|
||||
|
||||
extern void init_resolver(void);
|
||||
|
||||
struct hostent *unrealdns_doclient(aClient *cptr);
|
||||
|
||||
+3
-16
@@ -110,7 +110,7 @@ MODDBGCFLAG=/LD /MD
|
||||
!ENDIF
|
||||
|
||||
FD_SETSIZE=/D FD_SETSIZE=16384
|
||||
CFLAGS=$(DBGCFLAG) $(LIBCURL_INC) $(ZLIB_INC) $(OPENSSL_INC) /J /I ./INCLUDE /Fosrc/ /nologo \
|
||||
CFLAGS=$(DBGCFLAG) $(LIBCURL_INC) $(ZLIB_INC) $(OPENSSL_INC) /J /I ./INCLUDE /I ./INCLUDE/WIN32/ARES /Fosrc/ /nologo \
|
||||
$(ZIPCFLAGS) $(CURLCFLAGS) $(FD_SETSIZE) $(SSLCFLAGS) $(NS_ADDRESS) /D NOSPOOF=1 /c
|
||||
LFLAGS=kernel32.lib user32.lib gdi32.lib shell32.lib ws2_32.lib advapi32.lib \
|
||||
dbghelp.lib oldnames.lib comctl32.lib comdlg32.lib $(ZLIB_LIB) $(ZIPLIB) \
|
||||
@@ -134,8 +134,7 @@ EXP_OBJ_FILES=SRC/CHANNEL.OBJ SRC/SEND.OBJ SRC/SOCKET.OBJ \
|
||||
SRC/S_DEBUG.OBJ SRC/SUPPORT.OBJ SRC/LIST.OBJ \
|
||||
SRC/S_ERR.OBJ SRC/PACKET.OBJ SRC/S_BSD.OBJ \
|
||||
SRC/S_SERV.OBJ SRC/S_USER.OBJ SRC/CHARSYS.OBJ \
|
||||
SRC/VERSION.OBJ SRC/RES_INIT.OBJ SRC/RES_COMP.OBJ SRC/RES_MKQUERY.OBJ SRC/RES_SKIPNAME.OBJ \
|
||||
SRC/S_KLINE.OBJ SRC/S_EXTRA.OBJ SRC/IRCSPRINTF.OBJ SRC/LUSERS.OBJ \
|
||||
SRC/VERSION.OBJ SRC/S_KLINE.OBJ SRC/S_EXTRA.OBJ SRC/IRCSPRINTF.OBJ SRC/LUSERS.OBJ \
|
||||
SRC/SCACHE.OBJ SRC/ALN.OBJ SRC/BADWORDS.OBJ SRC/WEBTV.OBJ SRC/RES.OBJ SRC/MODULES.OBJ \
|
||||
SRC/S_SVS.OBJ SRC/EVENTS.OBJ SRC/UMODES.OBJ SRC/AUTH.OBJ SRC/CIDR.OBJ SRC/SSL.OBJ \
|
||||
SRC/RANDOM.OBJ SRC/EXTCMODES.OBJ SRC/MD5.OBJ SRC/API-ISUPPORT.OBJ SRC/API-COMMAND.OBJ \
|
||||
@@ -241,7 +240,7 @@ CONF:
|
||||
|
||||
|
||||
./WIRCD.EXE: $(OBJ_FILES) SRC/win32/WIN32.RES
|
||||
$(LINK) $(LFLAGS) $(OBJ_FILES) SRC/win32/WIN32.RES SRC/WIN32/TRE.LIB /MAPINFO:LINES /MAP
|
||||
$(LINK) $(LFLAGS) $(OBJ_FILES) SRC/win32/WIN32.RES SRC/WIN32/TRE.LIB SRC/WIN32/ARESLIB.LIB /MAPINFO:LINES /MAP
|
||||
-@erase src\win32\win32.res
|
||||
!IFNDEF DEBUG
|
||||
@echo Non Debug version built
|
||||
@@ -312,12 +311,6 @@ src/list.obj: src/list.c $(INCLUDES)
|
||||
src/res.obj: src/res.c $(INCLUDES)
|
||||
$(CC) $(CFLAGS) src/res.c
|
||||
|
||||
src/res_mkquery.obj: src/res_mkquery.c $(INCLUDES)
|
||||
$(CC) $(CFLAGS) src/res_mkquery.c
|
||||
|
||||
src/res_skipname.obj: src/res_skipname.c $(INCLUDES)
|
||||
$(CC) $(CFLAGS) src/res_skipname.c
|
||||
|
||||
src/s_bsd.obj: src/s_bsd.c $(INCLUDES)
|
||||
$(CC) $(CFLAGS) src/s_bsd.c
|
||||
|
||||
@@ -396,12 +389,6 @@ src/win32.obj: src/win32/win32.c $(INCLUDES)
|
||||
src/unreal.obj: src/win32/unreal.c $(INCLUDES)
|
||||
$(CC) $(CFLAGS) src/win32/unreal.c
|
||||
|
||||
src/res_comp.obj: src/res_comp.c $(INCLUDES)
|
||||
$(CC) $(CFLAGS) src/res_comp.c
|
||||
|
||||
src/res_init.obj: src/res_init.c $(INCLUDES)
|
||||
$(CC) $(CFLAGS) src/res_init.c
|
||||
|
||||
src/help.obj: src/help.c $(INCLUDES)
|
||||
$(CC) $(CFLAGS) src/help.c
|
||||
|
||||
|
||||
+6
-7
@@ -21,11 +21,10 @@
|
||||
|
||||
CC = danger will robinson
|
||||
|
||||
OBJS=auth.o aln.o badwords.o channel.o cloak.o crule.o dbuf.o \
|
||||
OBJS=res.o s_bsd.o auth.o aln.o badwords.o channel.o cloak.o crule.o dbuf.o \
|
||||
events.o fdlist.o hash.o help.o ircd.o ircsprintf.o list.o lusers.o \
|
||||
match.o modules.o packet.o parse.o res.o \
|
||||
res_init.o res_comp.o res_mkquery.o res_skipname.o s_auth.o \
|
||||
s_bsd.o s_conf.o s_debug.o s_err.o s_extra.o s_kline.o \
|
||||
match.o modules.o packet.o parse.o s_auth.o \
|
||||
s_conf.o s_debug.o s_err.o s_extra.o s_kline.o \
|
||||
s_misc.o s_numeric.o s_serv.o s_svs.o $(STRTOUL) socket.o \
|
||||
ssl.o s_user.o charsys.o scache.o send.o support.o umodes.o \
|
||||
version.o webtv.o whowas.o zip.o cidr.o random.o extcmodes.o \
|
||||
@@ -50,7 +49,7 @@ INCLUDES = ../include/auth.h ../include/badwords.h ../include/channel.h \
|
||||
../include/hash.h ../include/inet.h ../include/ircsprintf.h \
|
||||
../include/license.h ../include/macros.h ../include/md5.h \
|
||||
../include/modules.h ../include/modversion.h ../include/msg.h ../include/nameser.h \
|
||||
../include/numeric.h ../include/proto.h ../include/res.h ../include/resolv.h \
|
||||
../include/numeric.h ../include/proto.h \
|
||||
../include/resource.h ../include/setup.h ../include/sjoin.h \
|
||||
../include/sock.h ../include/ssl.h ../include/struct.h ../include/sys.h \
|
||||
../include/threads.h ../include/types.h ../include/url.h \
|
||||
@@ -181,7 +180,7 @@ list.o: list.c $(INCLUDES)
|
||||
lusers.o: lusers.c $(INCLUDES)
|
||||
$(CC) $(CFLAGS) -c lusers.c
|
||||
|
||||
res.o: res.c $(INCLUDES)
|
||||
res.o: res.c $(INCLUDES) ../include/res.h
|
||||
$(CC) $(CFLAGS) -c res.c
|
||||
|
||||
cloak.o: cloak.c $(INCLUDES)
|
||||
@@ -190,7 +189,7 @@ cloak.o: cloak.c $(INCLUDES)
|
||||
fdlist.o: fdlist.c $(INCLUDES)
|
||||
$(CC) $(CFLAGS) -c fdlist.c
|
||||
|
||||
s_bsd.o: s_bsd.c $(INCLUDES)
|
||||
s_bsd.o: s_bsd.c $(INCLUDES) ../include/res.h
|
||||
$(CC) $(CFLAGS) -c s_bsd.c
|
||||
|
||||
s_auth.o: s_auth.c $(INCLUDES)
|
||||
|
||||
@@ -48,6 +48,7 @@ MODVAR Event *events = NULL;
|
||||
#ifdef JOINTHROTTLE
|
||||
extern EVENT(cmodej_cleanup_structs);
|
||||
#endif
|
||||
extern EVENT(unrealdns_removeoldrecords);
|
||||
|
||||
void LockEventSystem(void)
|
||||
{
|
||||
@@ -220,5 +221,6 @@ void SetupEvents(void)
|
||||
#ifdef JOINTHROTTLE
|
||||
EventAddEx(NULL, "cmodej_cleanup_structs", 60, 0, cmodej_cleanup_structs, NULL);
|
||||
#endif
|
||||
EventAddEx(NULL, "unrealdns_removeoldrecords", 15, 0, unrealdns_removeoldrecords, NULL);
|
||||
UnlockEventSystem();
|
||||
}
|
||||
|
||||
+2
-8
@@ -662,7 +662,7 @@ extern TS check_pings(TS currenttime)
|
||||
Debug((DEBUG_NOTICE,
|
||||
"DNS/AUTH timeout %s",
|
||||
get_client_name(cptr, TRUE)));
|
||||
del_queries((char *)cptr);
|
||||
unrealdns_delreq_bycptr(cptr);
|
||||
ClearAuth(cptr);
|
||||
ClearDNS(cptr);
|
||||
SetAccess(cptr);
|
||||
@@ -1507,13 +1507,7 @@ void SocketLoop(void *dummy)
|
||||
*/
|
||||
if (nextconnect && timeofday >= nextconnect)
|
||||
nextconnect = try_connections(timeofday);
|
||||
/*
|
||||
* ** DNS checks. One to timeout queries, one for cache expiries.
|
||||
*/
|
||||
if (timeofday >= nextdnscheck)
|
||||
nextdnscheck = timeout_query_list(timeofday);
|
||||
if (timeofday >= nextexpire)
|
||||
nextexpire = expire_cache(timeofday);
|
||||
|
||||
/*
|
||||
* ** take the smaller of the two 'timed' event times as
|
||||
* ** the time of next event (stops us being late :) - avalon
|
||||
|
||||
@@ -560,7 +560,9 @@ void Unload_all_loaded_modules(void)
|
||||
}
|
||||
DelListItem(mi,Modules);
|
||||
irc_dlclose(mi->dll);
|
||||
#ifndef DEBUGMODE
|
||||
remove(mi->tmp_file);
|
||||
#endif
|
||||
MyFree(mi->tmp_file);
|
||||
MyFree(mi);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ INCLUDES = ../include/auth.h ../include/badwords.h ../include/channel.h \
|
||||
../include/hash.h ../include/inet.h ../include/ircsprintf.h \
|
||||
../include/license.h ../include/macros.h ../include/md5.h \
|
||||
../include/modules.h ../include/modversion.h ../include/msg.h ../include/nameser.h \
|
||||
../include/numeric.h ../include/proto.h ../include/res.h ../include/resolv.h \
|
||||
../include/numeric.h ../include/proto.h ../include/res.h \
|
||||
../include/resource.h ../include/setup.h ../include/sjoin.h \
|
||||
../include/sock.h ../include/ssl.h ../include/struct.h ../include/sys.h \
|
||||
../include/threads.h ../include/types.h ../include/url.h \
|
||||
|
||||
@@ -179,9 +179,15 @@ DLLFUNC CMD_FUNC(m_server)
|
||||
strcpy(xerrmsg, "Null servername");
|
||||
goto errlink;
|
||||
}
|
||||
for(link = conf_link; link; link = (ConfigItem_link *) link->next)
|
||||
if (!match(link->servername, servername))
|
||||
break;
|
||||
if (cptr->serv && cptr->serv->conf)
|
||||
{
|
||||
/* We already know what block we are dealing with (outgoing connect!) */
|
||||
link = cptr->serv->conf;
|
||||
} else {
|
||||
for(link = conf_link; link; link = (ConfigItem_link *) link->next)
|
||||
if (!match(link->servername, servername))
|
||||
break;
|
||||
}
|
||||
if (!link) {
|
||||
snprintf(xerrmsg, 256, "No link block named '%s'", servername);
|
||||
goto errlink;
|
||||
|
||||
+22
-2
@@ -496,6 +496,9 @@ int stats_banversion(aClient *sptr, char *para)
|
||||
int stats_links(aClient *sptr, char *para)
|
||||
{
|
||||
ConfigItem_link *link_p;
|
||||
#ifdef DEBUGMODE
|
||||
aClient *acptr;
|
||||
#endif
|
||||
for (link_p = conf_link; link_p; link_p = (ConfigItem_link *) link_p->next)
|
||||
{
|
||||
sendto_one(sptr, ":%s 213 %s C %s@%s * %s %i %s %s%s%s%s%s%s",
|
||||
@@ -510,7 +513,8 @@ int stats_links(aClient *sptr, char *para)
|
||||
(link_p->options & CONNECT_NOHOSTCHECK) ? "h" : "",
|
||||
(link_p->flag.temporary == 1) ? "T" : "");
|
||||
#ifdef DEBUGMODE
|
||||
sendnotice(sptr, "%s has refcount %d", link_p->servername, link_p->refcount);
|
||||
sendnotice(sptr, "%s (%p) has refcount %d",
|
||||
link_p->servername, link_p, link_p->refcount);
|
||||
#endif
|
||||
if (link_p->hubmask)
|
||||
sendto_one(sptr, ":%s 244 %s H %s * %s",
|
||||
@@ -521,6 +525,21 @@ int stats_links(aClient *sptr, char *para)
|
||||
me.name, sptr->name,
|
||||
link_p->leafmask, link_p->servername, link_p->leafdepth);
|
||||
}
|
||||
#ifdef DEBUGMODE
|
||||
for (acptr = client; acptr; acptr = acptr->next)
|
||||
if (MyConnect(acptr) && IsServer(acptr))
|
||||
{
|
||||
if (!acptr->serv->conf)
|
||||
sendnotice(sptr, "client '%s' (%p) has NO CONF attached (? :P)",
|
||||
acptr->name, acptr);
|
||||
else
|
||||
sendnotice(sptr, "client '%s' (%p) has conf %p attached, refcount: %d, temporary: %s",
|
||||
acptr->name, acptr,
|
||||
acptr->serv->conf,
|
||||
acptr->serv->conf->refcount,
|
||||
acptr->serv->conf->flag.temporary ? "YES" : "NO");
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -973,7 +992,8 @@ int stats_mem(aClient *sptr, char *para)
|
||||
fl, (long)(fl * sizeof(Link)),
|
||||
flinks, (long)(flinks * sizeof(Link)));
|
||||
|
||||
rm = cres_mem(sptr,sptr->name);
|
||||
// rm = cres_mem(sptr,sptr->name);
|
||||
rm = 0; // syzop: todo ??????????
|
||||
|
||||
tot = totww + totch + totcl + com + cl * sizeof(aClass) + db + rm;
|
||||
tot += fl * sizeof(Link);
|
||||
|
||||
-938
@@ -1,938 +0,0 @@
|
||||
/*
|
||||
* ++Copyright++ 1985, 1993
|
||||
* -
|
||||
* Copyright (c) 1985, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* -
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
* -
|
||||
* --Copyright--
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93";
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
||||
#include "struct.h"
|
||||
#include "common.h"
|
||||
#include "sys.h"
|
||||
#include "res.h"
|
||||
#include "numeric.h"
|
||||
#include "h.h"
|
||||
|
||||
#include <signal.h>
|
||||
#ifndef _WIN32
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#include "nameser.h"
|
||||
#include "resolv.h"
|
||||
#include <string.h>
|
||||
|
||||
static int ns_name_ntop(const u_char *, char *, size_t);
|
||||
static int ns_name_pton(const char *, u_char *, size_t);
|
||||
static int ns_name_unpack(const u_char *, const u_char *,
|
||||
const u_char *, u_char *, size_t);
|
||||
static int ns_name_pack(const u_char *, u_char *, int,
|
||||
const u_char **, const u_char **);
|
||||
static int ns_name_uncompress(const u_char *, const u_char *,
|
||||
const u_char *, char *, size_t);
|
||||
static int ns_name_compress(const char *, u_char *, size_t,
|
||||
const u_char **, const u_char **);
|
||||
static int ns_name_skip(const u_char **, const u_char *);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
int ircd_dn_expand(const u_char *msg, const u_char *eom, const u_char *src, char *dst, int dstsiz)
|
||||
{
|
||||
int n = ns_name_uncompress(msg, eom, src, dst, (size_t)dstsiz);
|
||||
|
||||
if (n > 0 && dst[0] == '.')
|
||||
dst[0] = '\0';
|
||||
return (n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Pack domain name 'exp_dn' in presentation form into 'comp_dn'.
|
||||
* Return the size of the compressed name or -1.
|
||||
* 'length' is the size of the array pointed to by 'comp_dn'.
|
||||
*/
|
||||
int ircd_dn_comp(const char *src, u_char *dst, int dstsiz, u_char **dnptrs, u_char **lastdnptr)
|
||||
{
|
||||
return (ns_name_compress(src, dst, (size_t)dstsiz,
|
||||
(const u_char **)dnptrs, (const u_char **)lastdnptr));
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip over a compressed domain name. Return the size or -1.
|
||||
*/
|
||||
int __ircd_dn_skipname(const u_char *ptr, const u_char *eom)
|
||||
{
|
||||
const u_char *saveptr = ptr;
|
||||
|
||||
if (ns_name_skip(&ptr, eom) == -1)
|
||||
return (-1);
|
||||
return (ptr - saveptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that a domain name uses an acceptable character set.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Note the conspicuous absence of ctype macros in these definitions. On
|
||||
* non-ASCII hosts, we can't depend on string literals or ctype macros to
|
||||
* tell us anything about network-format data. The rest of the BIND system
|
||||
* is not careful about this, but for some reason, we're doing it right here.
|
||||
*/
|
||||
#define PERIOD 0x2e
|
||||
#define hyphenchar(c) ((c) == 0x2d)
|
||||
#define bslashchar(c) ((c) == 0x5c)
|
||||
#define periodchar(c) ((c) == PERIOD)
|
||||
#define asterchar(c) ((c) == 0x2a)
|
||||
#define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \
|
||||
|| ((c) >= 0x61 && (c) <= 0x7a))
|
||||
#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39)
|
||||
|
||||
#define borderchar(c) (alphachar(c) || digitchar(c))
|
||||
#define middlechar(c) (borderchar(c) || hyphenchar(c))
|
||||
#define domainchar(c) ((c) > 0x20 && (c) < 0x7f)
|
||||
|
||||
#if 0
|
||||
/* it seems that we don't need these -krys */
|
||||
|
||||
int res_hnok(const char *dn)
|
||||
{
|
||||
int ppch = '\0', pch = PERIOD, ch = *dn++;
|
||||
|
||||
while (ch != '\0')
|
||||
{
|
||||
int nch = *dn++;
|
||||
|
||||
if (periodchar(ch))
|
||||
{
|
||||
NULL;
|
||||
}
|
||||
else if (periodchar(pch))
|
||||
{
|
||||
if (!borderchar(ch))
|
||||
return (0);
|
||||
}
|
||||
else if (periodchar(nch) || nch == '\0')
|
||||
{
|
||||
if (!borderchar(ch))
|
||||
return (0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!middlechar(ch))
|
||||
return (0);
|
||||
}
|
||||
ppch = pch, pch = ch, ch = nch;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* hostname-like (A, MX, WKS) owners can have "*" as their first label
|
||||
* but must otherwise be as a host name.
|
||||
*/
|
||||
int res_ownok(const char *dn)
|
||||
{
|
||||
if (asterchar(dn[0]))
|
||||
{
|
||||
if (periodchar(dn[1]))
|
||||
return (res_hnok(dn + 2));
|
||||
if (dn[1] == '\0')
|
||||
return (1);
|
||||
}
|
||||
return (res_hnok(dn));
|
||||
}
|
||||
|
||||
/*
|
||||
* SOA RNAMEs and RP RNAMEs can have any printable character in their first
|
||||
* label, but the rest of the name has to look like a host name.
|
||||
*/
|
||||
int res_mailok(const char *dn)
|
||||
{
|
||||
int ch, escaped = 0;
|
||||
|
||||
/* "." is a valid missing representation */
|
||||
if (*dn == '\0')
|
||||
return (1);
|
||||
|
||||
/* otherwise <label>.<hostname> */
|
||||
while ((ch = *dn++) != '\0')
|
||||
{
|
||||
if (!domainchar(ch))
|
||||
return (0);
|
||||
if (!escaped && periodchar(ch))
|
||||
break;
|
||||
if (escaped)
|
||||
escaped = 0;
|
||||
else if (bslashchar(ch))
|
||||
escaped = 1;
|
||||
}
|
||||
if (periodchar(ch))
|
||||
return (res_hnok(dn));
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is quite liberal, since RFC 1034's character sets are only
|
||||
* recommendations.
|
||||
*/
|
||||
int res_dnok(const char *dn)
|
||||
{
|
||||
int ch;
|
||||
|
||||
while ((ch = *dn++) != '\0')
|
||||
if (!domainchar(ch))
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Routines to insert/extract short/long's.
|
||||
*/
|
||||
|
||||
u_int16_t ircd_getshort(const u_char *msgp)
|
||||
{
|
||||
register u_int16_t u;
|
||||
|
||||
GETSHORT(u, msgp);
|
||||
return (u);
|
||||
}
|
||||
|
||||
u_int32_t ircd_getlong(const u_char *msgp)
|
||||
{
|
||||
register u_int32_t u;
|
||||
|
||||
GETLONG(u, msgp);
|
||||
return (u);
|
||||
}
|
||||
|
||||
void
|
||||
ircd__putshort(register u_int16_t s, register u_char *msgp) /* must match proto */
|
||||
{
|
||||
PUTSHORT(s, msgp);
|
||||
}
|
||||
|
||||
void ircd__putlong(register u_int32_t l,register u_char *msgp)
|
||||
{
|
||||
PUTLONG(l, msgp);
|
||||
}
|
||||
|
||||
/* ++ From BIND 8.1.1. ++ */
|
||||
/*
|
||||
* Copyright (c) 1996 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*"Id: ns_name.c,v 1.1 1997/12/13 02:41:13 vixie Exp vixie"*/
|
||||
|
||||
/*#include "port_before.h"*/
|
||||
|
||||
/*#include <sys/types.h>*/
|
||||
|
||||
/*#include <netinet/in.h>*/
|
||||
/*#include <arpa/nameser.h>*/
|
||||
|
||||
/*#include <errno.h>*/
|
||||
/*#include <resolv.h>*/
|
||||
/*#include <string.h>*/
|
||||
|
||||
/*#include "port_after.h"*/
|
||||
|
||||
#define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */
|
||||
#define NS_MAXCDNAME 255 /* maximum compressed domain name */
|
||||
|
||||
/* Data. */
|
||||
|
||||
static char digits[] = "0123456789";
|
||||
|
||||
/* Forward. */
|
||||
|
||||
static int special(int);
|
||||
static int printable(int);
|
||||
static int dn_find(const u_char *, const u_char *,
|
||||
const u_char *const *, const u_char *const *);
|
||||
|
||||
/* Public. */
|
||||
|
||||
/*
|
||||
* ns_name_ntop(src, dst, dstsiz)
|
||||
* Convert an encoded domain name to printable ascii as per RFC1035.
|
||||
* return:
|
||||
* Number of bytes written to buffer, or -1 (with errno set)
|
||||
* notes:
|
||||
* The root is returned as "."
|
||||
* All other domains are returned in non absolute form
|
||||
*/
|
||||
static int ns_name_ntop(const u_char *src, char *dst, size_t dstsiz)
|
||||
{
|
||||
const u_char *cp;
|
||||
char *dn, *eom;
|
||||
u_char c;
|
||||
u_int n;
|
||||
|
||||
cp = src;
|
||||
dn = dst;
|
||||
eom = dst + dstsiz;
|
||||
|
||||
while ((n = *cp++) != 0)
|
||||
{
|
||||
if ((n & NS_CMPRSFLGS) != 0)
|
||||
{
|
||||
/* Some kind of compression pointer. */
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
if (dn != dst)
|
||||
{
|
||||
if (dn >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
*dn++ = '.';
|
||||
}
|
||||
if (dn + n >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
for ((void)NULL; n > 0; n--)
|
||||
{
|
||||
c = *cp++;
|
||||
if (special(c))
|
||||
{
|
||||
if (dn + 1 >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
*dn++ = '\\';
|
||||
*dn++ = (char)c;
|
||||
}
|
||||
else if (!printable(c))
|
||||
{
|
||||
if (dn + 3 >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
*dn++ = '\\';
|
||||
*dn++ = digits[c / 100];
|
||||
*dn++ = digits[(c % 100) / 10];
|
||||
*dn++ = digits[c % 10];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dn >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
*dn++ = (char)c;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dn == dst)
|
||||
{
|
||||
if (dn >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
*dn++ = '.';
|
||||
}
|
||||
if (dn >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
*dn++ = '\0';
|
||||
return (dn - dst);
|
||||
}
|
||||
|
||||
/*
|
||||
* ns_name_pton(src, dst, dstsiz)
|
||||
* Convert a ascii string into an encoded domain name as per RFC1035.
|
||||
* return:
|
||||
* -1 if it fails
|
||||
* 1 if string was fully qualified
|
||||
* 0 is string was not fully qualified
|
||||
* notes:
|
||||
* Enforces label and domain length limits.
|
||||
*/
|
||||
|
||||
static int ns_name_pton(const char *src, u_char *dst, size_t dstsiz)
|
||||
{
|
||||
u_char *label, *bp, *eom;
|
||||
int c, n, escaped;
|
||||
char *cp;
|
||||
|
||||
escaped = 0;
|
||||
bp = dst;
|
||||
eom = dst + dstsiz;
|
||||
label = bp++;
|
||||
|
||||
while ((c = *src++) != 0)
|
||||
{
|
||||
if (escaped)
|
||||
{
|
||||
if ((cp = strchr(digits, c)) != NULL)
|
||||
{
|
||||
n = (cp - digits) * 100;
|
||||
if ((c = *src++) == 0 ||
|
||||
(cp = strchr(digits, c)) == NULL)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
n += (cp - digits) * 10;
|
||||
if ((c = *src++) == 0 ||
|
||||
(cp = strchr(digits, c)) == NULL)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
n += (cp - digits);
|
||||
if (n > 255)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
c = n;
|
||||
}
|
||||
escaped = 0;
|
||||
}
|
||||
else if (c == '\\')
|
||||
{
|
||||
escaped = 1;
|
||||
continue;
|
||||
}
|
||||
else if (c == '.')
|
||||
{
|
||||
c = (bp - label - 1);
|
||||
if ((c & NS_CMPRSFLGS) != 0)
|
||||
{ /* Label too big. */
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
if (label >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
*label = c;
|
||||
/* Fully qualified ? */
|
||||
if (*src == '\0')
|
||||
{
|
||||
if (c != 0)
|
||||
{
|
||||
if (bp >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
*bp++ = '\0';
|
||||
}
|
||||
if ((bp - dst) > MAXCDNAME)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
if (c == 0)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
label = bp++;
|
||||
continue;
|
||||
}
|
||||
if (bp >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
*bp++ = (u_char)c;
|
||||
}
|
||||
c = (bp - label - 1);
|
||||
if ((c & NS_CMPRSFLGS) != 0)
|
||||
{ /* Label too big. */
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
if (label >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
*label = c;
|
||||
if (c != 0)
|
||||
{
|
||||
if (bp >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
*bp++ = 0;
|
||||
}
|
||||
if ((bp - dst) > MAXCDNAME)
|
||||
{ /* src too big */
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* ns_name_unpack(msg, eom, src, dst, dstsiz)
|
||||
* Unpack a domain name from a message, source may be compressed.
|
||||
* return:
|
||||
* -1 if it fails, or consumed octets if it succeeds.
|
||||
*/
|
||||
static int ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src, u_char *dst, size_t dstsiz)
|
||||
{
|
||||
const u_char *srcp, *dstlim;
|
||||
u_char *dstp;
|
||||
int n, len, checked;
|
||||
|
||||
len = -1;
|
||||
checked = 0;
|
||||
dstp = dst;
|
||||
srcp = src;
|
||||
dstlim = dst + dstsiz;
|
||||
if (srcp < msg || srcp >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
/* Fetch next label in domain name. */
|
||||
while ((n = *srcp++) != 0)
|
||||
{
|
||||
/* Check for indirection. */
|
||||
switch (n & NS_CMPRSFLGS)
|
||||
{
|
||||
case 0:
|
||||
/* Limit checks. */
|
||||
if (dstp + n + 1 >= dstlim || srcp + n >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
checked += n + 1;
|
||||
*dstp++ = n;
|
||||
memcpy(dstp, srcp, n);
|
||||
dstp += n;
|
||||
srcp += n;
|
||||
break;
|
||||
|
||||
case NS_CMPRSFLGS:
|
||||
if (srcp >= eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
if (len < 0)
|
||||
len = srcp - src + 1;
|
||||
srcp = msg + (((n & 0x3f) << 8) | (*srcp & 0xff));
|
||||
if (srcp < msg || srcp >= eom)
|
||||
{ /* Out of range. */
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
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 >= eom - msg)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1); /* flag error */
|
||||
}
|
||||
}
|
||||
*dstp = '\0';
|
||||
if (len < 0)
|
||||
len = srcp - src;
|
||||
return (len);
|
||||
}
|
||||
|
||||
/*
|
||||
* ns_name_pack(src, dst, dstsiz, dnptrs, lastdnptr)
|
||||
* Pack domain name 'domain' into 'comp_dn'.
|
||||
* return:
|
||||
* Size of the compressed name, or -1.
|
||||
* notes:
|
||||
* 'dnptrs' is an array of pointers to previous compressed names.
|
||||
* dnptrs[0] is a pointer to the beginning of the message. The array
|
||||
* ends with NULL.
|
||||
* 'lastdnptr' is a pointer to the end of the array pointed to
|
||||
* by 'dnptrs'.
|
||||
* Side effects:
|
||||
* The list of pointers in dnptrs is updated 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.
|
||||
*/
|
||||
static int ns_name_pack(const u_char *src, u_char *dst, int dstsiz, const u_char **dnptrs, const u_char **lastdnptr)
|
||||
{
|
||||
u_char *dstp;
|
||||
const u_char **cpp, **lpp, *eob, *msg;
|
||||
const u_char *srcp;
|
||||
int n, l;
|
||||
|
||||
srcp = src;
|
||||
dstp = dst;
|
||||
eob = dstp + dstsiz;
|
||||
lpp = cpp = NULL;
|
||||
if (dnptrs != NULL)
|
||||
{
|
||||
if ((msg = *dnptrs++) != NULL)
|
||||
{
|
||||
for (cpp = dnptrs; *cpp != NULL; cpp++)
|
||||
(void)NULL;
|
||||
lpp = cpp; /* end of list to search */
|
||||
}
|
||||
}
|
||||
else
|
||||
msg = NULL;
|
||||
|
||||
/* make sure the domain we are about to add is legal */
|
||||
l = 0;
|
||||
do
|
||||
{
|
||||
n = *srcp;
|
||||
if ((n & NS_CMPRSFLGS) != 0)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
l += n + 1;
|
||||
if (l > MAXCDNAME)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
srcp += n + 1;
|
||||
}
|
||||
while (n != 0);
|
||||
|
||||
srcp = src;
|
||||
do
|
||||
{
|
||||
/* Look to see if we can use pointers. */
|
||||
n = *srcp;
|
||||
if (n != 0 && msg != NULL)
|
||||
{
|
||||
l = dn_find(srcp, msg, (const u_char *const *)dnptrs,
|
||||
(const u_char *const *)lpp);
|
||||
if (l >= 0)
|
||||
{
|
||||
if (dstp + 1 >= eob)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
*dstp++ = (l >> 8) | NS_CMPRSFLGS;
|
||||
*dstp++ = l % 256;
|
||||
return (dstp - dst);
|
||||
}
|
||||
/* Not found, save it. */
|
||||
if (lastdnptr != NULL && cpp < lastdnptr - 1 &&
|
||||
(dstp - msg) < 0x4000)
|
||||
{
|
||||
*cpp++ = dstp;
|
||||
*cpp = NULL;
|
||||
}
|
||||
}
|
||||
/* copy label to buffer */
|
||||
if (n & NS_CMPRSFLGS)
|
||||
{ /* Should not happen. */
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
if (dstp + 1 + n >= eob)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
memcpy(dstp, srcp, n + 1);
|
||||
srcp += n + 1;
|
||||
dstp += n + 1;
|
||||
}
|
||||
while (n != 0);
|
||||
|
||||
if (dstp > eob)
|
||||
{
|
||||
if (msg != NULL)
|
||||
*lpp = NULL;
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
return (dstp - dst);
|
||||
}
|
||||
|
||||
/*
|
||||
* ns_name_uncompress(msg, eom, src, dst, dstsiz)
|
||||
* Expand compressed domain name to presentation format.
|
||||
* return:
|
||||
* Number of bytes read out of `src', or -1 (with errno set).
|
||||
* note:
|
||||
* Root domain returns as "." not "".
|
||||
*/
|
||||
static int ns_name_uncompress(const u_char *msg, const u_char *eom, const u_char *src, char *dst, size_t dstsiz)
|
||||
{
|
||||
u_char tmp[NS_MAXCDNAME];
|
||||
int n;
|
||||
|
||||
if ((n = ns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1)
|
||||
return (-1);
|
||||
if (ns_name_ntop(tmp, dst, dstsiz) == -1)
|
||||
return (-1);
|
||||
return (n);
|
||||
}
|
||||
|
||||
/*
|
||||
* ns_name_compress(src, dst, dstsiz, dnptrs, lastdnptr)
|
||||
* Compress a domain name into wire format, using compression pointers.
|
||||
* return:
|
||||
* Number of bytes consumed in `dst' or -1 (with errno set).
|
||||
* notes:
|
||||
* 'dnptrs' is an array 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
|
||||
* array 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.
|
||||
*/
|
||||
static int ns_name_compress(const char *src, u_char *dst, size_t dstsiz, const u_char **dnptrs,
|
||||
const u_char **lastdnptr)
|
||||
{
|
||||
u_char tmp[NS_MAXCDNAME];
|
||||
|
||||
if (ns_name_pton(src, tmp, sizeof tmp) == -1)
|
||||
return (-1);
|
||||
return (ns_name_pack(tmp, dst, dstsiz, dnptrs, lastdnptr));
|
||||
}
|
||||
|
||||
/*
|
||||
* ns_name_skip(ptrptr, eom)
|
||||
* Advance *ptrptr to skip over the compressed name it points at.
|
||||
* return:
|
||||
* 0 on success, -1 (with errno set) on failure.
|
||||
*/
|
||||
static int ns_name_skip(const u_char **ptrptr, const u_char *eom)
|
||||
{
|
||||
const u_char *cp;
|
||||
u_int n;
|
||||
|
||||
cp = *ptrptr;
|
||||
while (cp < eom && (n = *cp++) != 0)
|
||||
{
|
||||
/* Check for indirection. */
|
||||
switch (n & NS_CMPRSFLGS)
|
||||
{
|
||||
case 0: /* normal case, n == len */
|
||||
cp += n;
|
||||
continue;
|
||||
case NS_CMPRSFLGS: /* indirection */
|
||||
cp++;
|
||||
break;
|
||||
default: /* illegal type */
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (cp > eom)
|
||||
{
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
*ptrptr = cp;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Private. */
|
||||
|
||||
/*
|
||||
* special(ch)
|
||||
* Thinking in noninternationalized USASCII (per the DNS spec),
|
||||
* is this characted special ("in need of quoting") ?
|
||||
* return:
|
||||
* boolean.
|
||||
*/
|
||||
static int special(int ch)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case 0x22: /* '"' */
|
||||
case 0x2E: /* '.' */
|
||||
case 0x3B: /* ';' */
|
||||
case 0x5C: /* '\\' */
|
||||
/* Special modifiers in zone files. */
|
||||
case 0x40: /* '@' */
|
||||
case 0x24: /* '$' */
|
||||
return (1);
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* printable(ch)
|
||||
* Thinking in noninternationalized USASCII (per the DNS spec),
|
||||
* is this character visible and not a space when printed ?
|
||||
* return:
|
||||
* boolean.
|
||||
*/
|
||||
static int printable(int ch)
|
||||
{
|
||||
return (ch > 0x20 && ch < 0x7f);
|
||||
}
|
||||
|
||||
/*
|
||||
* Thinking in noninternationalized USASCII (per the DNS spec),
|
||||
* convert this character to lower case if it's upper case.
|
||||
*/
|
||||
static int mklower(int ch)
|
||||
{
|
||||
if (ch >= 0x41 && ch <= 0x5A)
|
||||
return (ch + 0x20);
|
||||
return (ch);
|
||||
}
|
||||
|
||||
/*
|
||||
* dn_find(domain, msg, dnptrs, lastdnptr)
|
||||
* Search for the counted-label name in an array of compressed names.
|
||||
* return:
|
||||
* offset from msg if found, or -1.
|
||||
* notes:
|
||||
* dnptrs is the pointer to the first name on the list,
|
||||
* not the pointer to the start of the message.
|
||||
*/
|
||||
static int dn_find(const u_char *domain, const u_char *msg, const u_char *const *dnptrs,
|
||||
const u_char *const *lastdnptr)
|
||||
{
|
||||
const u_char *dn, *cp, *sp;
|
||||
const u_char *const *cpp;
|
||||
u_int n;
|
||||
|
||||
for (cpp = dnptrs; cpp < lastdnptr; cpp++)
|
||||
{
|
||||
dn = domain;
|
||||
sp = cp = *cpp;
|
||||
while ((n = *cp++) != 0)
|
||||
{
|
||||
/*
|
||||
* check for indirection
|
||||
*/
|
||||
switch (n & NS_CMPRSFLGS)
|
||||
{
|
||||
case 0: /* normal case, n == len */
|
||||
if (n != *dn++)
|
||||
goto next;
|
||||
for ((void)NULL; n > 0; n--)
|
||||
if (mklower(*dn++) != mklower(*cp++))
|
||||
goto next;
|
||||
/* Is next root for both ? */
|
||||
if (*dn == '\0' && *cp == '\0')
|
||||
return (sp - msg);
|
||||
if (*dn)
|
||||
continue;
|
||||
goto next;
|
||||
|
||||
case NS_CMPRSFLGS: /* indirection */
|
||||
cp = msg + (((n & 0x3f) << 8) | *cp);
|
||||
break;
|
||||
|
||||
default: /* illegal type */
|
||||
SET_ERRNO(P_EMSGSIZE);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
next:;
|
||||
}
|
||||
SET_ERRNO(ENOENT);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* -- From BIND 8.1.1. -- */
|
||||
-1128
File diff suppressed because it is too large
Load Diff
@@ -1,185 +0,0 @@
|
||||
/*
|
||||
* ++Copyright++ 1985, 1993
|
||||
* -
|
||||
* Copyright (c) 1985, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* -
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
* -
|
||||
* --Copyright--
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "struct.h"
|
||||
#include "common.h"
|
||||
#include "sys.h"
|
||||
#include "res.h"
|
||||
#include "numeric.h"
|
||||
#include "h.h"
|
||||
|
||||
#include <signal.h>
|
||||
#ifndef _WIN32
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#include "nameser.h"
|
||||
#include "resolv.h"
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Form all types of queries.
|
||||
* Returns the size of the result or -1.
|
||||
*/
|
||||
int
|
||||
ircd_res_mkquery(int op, const char *dname, int class, int type, const u_char *data, int datalen,
|
||||
const u_char *newrr_in, u_char *buf, int buflen)
|
||||
{
|
||||
register HEADER *hp;
|
||||
register u_char *cp;
|
||||
register int n;
|
||||
u_char *dnptrs[20], **dpp, **lastdnptr;
|
||||
|
||||
if ((ircd_res.options & RES_INIT) == 0 && ircd_res_init() == -1)
|
||||
{
|
||||
SET_ERRNO(NETDB_INTERNAL);
|
||||
return (-1);
|
||||
}
|
||||
#ifdef DEBUGMODE
|
||||
Debug((DEBUG_DNS,
|
||||
";; res_mkquery(%d, %s, %d, %d)",
|
||||
op, dname, class, type));
|
||||
#endif
|
||||
/*
|
||||
* Initialize header fields.
|
||||
*/
|
||||
if ((buf == NULL) || (buflen < HFIXEDSZ))
|
||||
return (-1);
|
||||
bzero(buf, HFIXEDSZ);
|
||||
hp = (HEADER *) buf;
|
||||
hp->id = htons(++ircd_res.id);
|
||||
hp->opcode = op;
|
||||
hp->rd = (ircd_res.options & RES_RECURSE) != 0;
|
||||
hp->rcode = NOERROR;
|
||||
cp = buf + HFIXEDSZ;
|
||||
buflen -= HFIXEDSZ;
|
||||
dpp = dnptrs;
|
||||
*dpp++ = buf;
|
||||
*dpp++ = NULL;
|
||||
lastdnptr = dnptrs + sizeof dnptrs / sizeof dnptrs[0];
|
||||
/*
|
||||
* perform opcode specific processing
|
||||
*/
|
||||
switch (op)
|
||||
{
|
||||
case QUERY:
|
||||
/*FALLTHROUGH*/ case NS_NOTIFY_OP:
|
||||
if ((buflen -= QFIXEDSZ) < 0)
|
||||
return (-1);
|
||||
if ((n =
|
||||
ircd_dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
|
||||
return (-1);
|
||||
cp += n;
|
||||
buflen -= n;
|
||||
ircd__putshort(type, cp);
|
||||
cp += INT16SZ;
|
||||
ircd__putshort(class, cp);
|
||||
cp += INT16SZ;
|
||||
hp->qdcount = htons(1);
|
||||
if (op == QUERY || data == NULL)
|
||||
break;
|
||||
/*
|
||||
* Make an additional record for completion domain.
|
||||
*/
|
||||
buflen -= RRFIXEDSZ;
|
||||
n = ircd_dn_comp((char *)data, cp, buflen, dnptrs, lastdnptr);
|
||||
if (n < 0)
|
||||
return (-1);
|
||||
cp += n;
|
||||
buflen -= n;
|
||||
ircd__putshort(T_NULL, cp);
|
||||
cp += INT16SZ;
|
||||
ircd__putshort(class, cp);
|
||||
cp += INT16SZ;
|
||||
ircd__putlong(0, cp);
|
||||
cp += INT32SZ;
|
||||
ircd__putshort(0, cp);
|
||||
cp += INT16SZ;
|
||||
hp->arcount = htons(1);
|
||||
break;
|
||||
|
||||
case IQUERY:
|
||||
/*
|
||||
* Initialize answer section
|
||||
*/
|
||||
if (buflen < 1 + RRFIXEDSZ + datalen)
|
||||
return (-1);
|
||||
*cp++ = '\0'; /* no domain name */
|
||||
ircd__putshort(type, cp);
|
||||
cp += INT16SZ;
|
||||
ircd__putshort(class, cp);
|
||||
cp += INT16SZ;
|
||||
ircd__putlong(0, cp);
|
||||
cp += INT32SZ;
|
||||
ircd__putshort(datalen, cp);
|
||||
cp += INT16SZ;
|
||||
if (datalen)
|
||||
{
|
||||
bcopy(data, cp, datalen);
|
||||
cp += datalen;
|
||||
}
|
||||
hp->ancount = htons(1);
|
||||
break;
|
||||
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
return (cp - buf);
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include "nameser.h"
|
||||
#include "common.h"
|
||||
|
||||
/*
|
||||
* Skip over a compressed domain name. Return the size or -1.
|
||||
*/
|
||||
int dn_skipname(u_char *comp_dn, u_char *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);
|
||||
}
|
||||
+1
-1
@@ -24,7 +24,6 @@ static char sccsid[] = "@(#)s_auth.c 1.18 4/18/94 (C) 1992 Darren Reed";
|
||||
#include "struct.h"
|
||||
#include "common.h"
|
||||
#include "sys.h"
|
||||
#include "res.h"
|
||||
#include "numeric.h"
|
||||
#include "version.h"
|
||||
#ifndef _WIN32
|
||||
@@ -41,6 +40,7 @@ static char sccsid[] = "@(#)s_auth.c 1.18 4/18/94 (C) 1992 Darren Reed";
|
||||
#include "sock.h" /* If FD_ZERO isn't define up to this point, */
|
||||
/* define it (BSD4.2 needs this) */
|
||||
#include "h.h"
|
||||
#include "res.h"
|
||||
#include "proto.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
+44
-144
@@ -66,7 +66,6 @@ Computing Center and Jarkko Oikarinen";
|
||||
#else
|
||||
# include "nameser.h"
|
||||
#endif
|
||||
#include "resolv.h"
|
||||
#include "sock.h" /* If FD_ZERO isn't define up to this point, */
|
||||
#include <string.h>
|
||||
#include "proto.h"
|
||||
@@ -106,7 +105,7 @@ extern char backupbuf[8192];
|
||||
aClient *local[MAXCONNECTIONS];
|
||||
short LastSlot = -1; /* GLOBAL - last used slot in local */
|
||||
int OpenFiles = 0; /* GLOBAL - number of files currently open */
|
||||
int readcalls = 0, resfd = -1;
|
||||
int readcalls = 0;
|
||||
static struct SOCKADDR_IN mysk;
|
||||
|
||||
static struct SOCKADDR *connect_inet(ConfigItem_link *, aClient *, int *);
|
||||
@@ -149,7 +148,8 @@ extern void url_do_transfers_async(void);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
void start_of_normal_client_handshake(aClient *acptr);
|
||||
void start_of_normal_client_handshake(aClient *acptr);
|
||||
void proceed_normal_client_handshake(aClient *acptr, struct hostent *he);
|
||||
|
||||
/* winlocal */
|
||||
void add_local_client(aClient* cptr)
|
||||
@@ -208,8 +208,6 @@ void close_connections(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
CLOSE_SOCK(resfd);
|
||||
resfd = -1;
|
||||
OpenFiles = 0;
|
||||
LastSlot = -1;
|
||||
#ifdef _WIN32
|
||||
@@ -225,7 +223,7 @@ void close_connections(void)
|
||||
|
||||
void add_local_domain(char *hname, int size)
|
||||
{
|
||||
#ifdef RES_INIT
|
||||
#if 0
|
||||
/* try to fix up unqualified names */
|
||||
if (!index(hname, '.'))
|
||||
{
|
||||
@@ -671,8 +669,7 @@ init_dgram:
|
||||
|
||||
#endif /*_WIN32*/
|
||||
|
||||
resfd = init_resolver(0x1f);
|
||||
Debug((DEBUG_DNS, "resfd %d", resfd));
|
||||
init_resolver();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -902,7 +899,7 @@ void close_connection(aClient *cptr)
|
||||
/*
|
||||
* remove outstanding DNS queries.
|
||||
*/
|
||||
del_queries((char *)cptr);
|
||||
unrealdns_delreq_bycptr(cptr);
|
||||
/*
|
||||
* If the connection has been up for a long amount of time, schedule
|
||||
* a 'quick' reconnect, else reset the next-connect cycle.
|
||||
@@ -1351,29 +1348,31 @@ add_con_refuse:
|
||||
|
||||
void start_of_normal_client_handshake(aClient *acptr)
|
||||
{
|
||||
Link lin;
|
||||
acptr->status = STAT_UNKNOWN;
|
||||
if (DONT_RESOLVE)
|
||||
goto skipdns;
|
||||
if (SHOWCONNECTINFO && !acptr->serv)
|
||||
sendto_one(acptr, "%s", REPORT_DO_DNS);
|
||||
lin.flags = ASYNC_CLIENT;
|
||||
lin.value.cptr = acptr;
|
||||
Debug((DEBUG_DNS, "lookup %s", acptr->sockhost));
|
||||
acptr->hostp = gethost_byaddr((char *)&acptr->ip, &lin);
|
||||
|
||||
if (!acptr->hostp)
|
||||
SetDNS(acptr);
|
||||
else
|
||||
if (!DONT_RESOLVE)
|
||||
{
|
||||
if (SHOWCONNECTINFO && !acptr->serv)
|
||||
sendto_one(acptr, "%s", REPORT_FIN_DNSC);
|
||||
acptr->hostp = unrealdns_doclient(acptr);
|
||||
if (!acptr->hostp)
|
||||
{
|
||||
SetDNS(acptr);
|
||||
} else {
|
||||
if (SHOWCONNECTINFO && !acptr->serv)
|
||||
sendto_one(acptr, "%s", REPORT_FIN_DNSC);
|
||||
}
|
||||
}
|
||||
nextdnscheck = 1;
|
||||
skipdns:
|
||||
start_auth(acptr);
|
||||
}
|
||||
|
||||
void proceed_normal_client_handshake(aClient *acptr, struct hostent *he)
|
||||
{
|
||||
ClearDNS(acptr);
|
||||
acptr->hostp = he;
|
||||
if (SHOWCONNECTINFO && !acptr->serv)
|
||||
sendto_one(acptr, "%s", acptr->hostp ? REPORT_FIN_DNS : REPORT_FAIL_DNS);
|
||||
|
||||
if (!DoingAuth(acptr))
|
||||
SetAccess(acptr);
|
||||
}
|
||||
|
||||
/*
|
||||
** read_packet
|
||||
**
|
||||
@@ -1730,8 +1729,8 @@ int read_message(time_t delay, fdlist *listp)
|
||||
}
|
||||
}
|
||||
|
||||
if (resfd >= 0)
|
||||
FD_SET(resfd, &read_set);
|
||||
ares_fds(resolver_channel, &read_set, &write_set);
|
||||
|
||||
if (me.fd >= 0)
|
||||
FD_SET(me.fd, &read_set);
|
||||
|
||||
@@ -1761,13 +1760,10 @@ int read_message(time_t delay, fdlist *listp)
|
||||
Sleep(10000);
|
||||
#endif
|
||||
}
|
||||
if (resfd >= 0 && FD_ISSET(resfd, &read_set))
|
||||
{
|
||||
Debug((DEBUG_DNS, "Doing DNS async.."));
|
||||
do_dns_async();
|
||||
nfds--;
|
||||
FD_CLR(resfd, &read_set);
|
||||
}
|
||||
|
||||
Debug((DEBUG_DNS, "Doing DNS async.."));
|
||||
ares_process(resolver_channel, &read_set, &write_set);
|
||||
|
||||
/*
|
||||
* Check fd sets for the auth fd's (if set and valid!) first
|
||||
* because these can not be processed using the normal loops below.
|
||||
@@ -2165,11 +2161,7 @@ int read_message(time_t delay, fdlist *listp)
|
||||
PFD_SETW(i);
|
||||
}
|
||||
|
||||
if (resfd >= 0)
|
||||
{
|
||||
PFD_SETR(resfd);
|
||||
res_pfd = pfd;
|
||||
}
|
||||
__THIS__CODE__DOES__NOT__WORK__
|
||||
|
||||
/* FIXME: no ZIP link handling here, but this code doesnt work anyway -- Syzop */
|
||||
|
||||
@@ -2368,6 +2360,11 @@ int connect_server(ConfigItem_link *aconf, aClient *by, struct hostent *hp)
|
||||
char *s;
|
||||
int errtmp, len;
|
||||
|
||||
#ifdef DEBUGMODE
|
||||
sendto_realops("connect_server() called with aconf %p, refcount: %d, TEMP: %s",
|
||||
aconf, aconf->refcount, aconf->flag.temporary ? "YES" : "NO");
|
||||
#endif
|
||||
|
||||
if (aconf->options & CONNECT_NODNSCACHE) {
|
||||
/* Remove "cache" if link::options::nodnscache is set */
|
||||
memset(&aconf->ipnum, '\0', sizeof(struct IN_ADDR));
|
||||
@@ -2378,10 +2375,6 @@ int connect_server(ConfigItem_link *aconf, aClient *by, struct hostent *hp)
|
||||
*/
|
||||
if (!WHOSTENTP(aconf->ipnum.S_ADDR))
|
||||
{
|
||||
Link lin;
|
||||
|
||||
lin.flags = ASYNC_CONNECT;
|
||||
lin.value.aconf = (ListStruct *) aconf;
|
||||
nextdnscheck = 1;
|
||||
s = aconf->hostname;
|
||||
#ifndef INET6
|
||||
@@ -2395,11 +2388,8 @@ int connect_server(ConfigItem_link *aconf, aClient *by, struct hostent *hp)
|
||||
#else
|
||||
aconf->ipnum.S_ADDR = 0;
|
||||
#endif
|
||||
hp = gethost_byname(s, &lin);
|
||||
if (!hp)
|
||||
return -2;
|
||||
bcopy(hp->h_addr, (char *)&aconf->ipnum,
|
||||
sizeof(struct IN_ADDR));
|
||||
unrealdns_gethostbyname_link(aconf->hostname, aconf);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
cptr = make_client(NULL, NULL);
|
||||
@@ -2456,6 +2446,10 @@ int connect_server(ConfigItem_link *aconf, aClient *by, struct hostent *hp)
|
||||
(void)make_server(cptr);
|
||||
cptr->serv->conf = aconf;
|
||||
cptr->serv->conf->refcount++;
|
||||
#ifdef DEBUGMODE
|
||||
sendto_realops("connect_server() CONTINUED (%s:%d), aconf %p, refcount: %d, TEMP: %s",
|
||||
__FILE__, __LINE__, aconf, aconf->refcount, aconf->flag.temporary ? "YES" : "NO");
|
||||
#endif
|
||||
Debug((DEBUG_ERROR, "reference count for %s (%s) is now %d",
|
||||
cptr->name, cptr->serv->conf->servername, cptr->serv->conf->refcount));
|
||||
if (by && IsPerson(by))
|
||||
@@ -2564,97 +2558,3 @@ static struct SOCKADDR *connect_inet(ConfigItem_link *aconf, aClient *cptr, int
|
||||
*lenp = sizeof(server);
|
||||
return (struct SOCKADDR *)&server;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* do_dns_async
|
||||
*
|
||||
* Called when the fd returned from init_resolver() has been selected for
|
||||
* reading.
|
||||
*/
|
||||
|
||||
static void do_dns_async(void)
|
||||
{
|
||||
static Link ln;
|
||||
aClient *cptr;
|
||||
ConfigItem_link *aconf;
|
||||
struct hostent *hp;
|
||||
int bytes, pkts;
|
||||
|
||||
pkts = 0;
|
||||
|
||||
do {
|
||||
ln.flags = -1;
|
||||
hp = get_res((char *)&ln);
|
||||
Debug((DEBUG_DNS,"%#x = get_res(%d,%#x)", hp, ln.flags,
|
||||
ln.value.cptr));
|
||||
|
||||
switch (ln.flags)
|
||||
{
|
||||
case ASYNC_NONE :
|
||||
/*
|
||||
* no reply was processed that was outstanding or
|
||||
* had a client still waiting.
|
||||
*/
|
||||
break;
|
||||
case ASYNC_CLIENT :
|
||||
if ((cptr = ln.value.cptr))
|
||||
{
|
||||
del_queries((char *)cptr);
|
||||
ClearDNS(cptr);
|
||||
cptr->hostp = hp;
|
||||
|
||||
if (SHOWCONNECTINFO && !cptr->serv)
|
||||
sendto_one(cptr, "%s", cptr->hostp ? REPORT_FIN_DNS : REPORT_FAIL_DNS);
|
||||
if (!DoingAuth(cptr))
|
||||
SetAccess(cptr);
|
||||
}
|
||||
break;
|
||||
case ASYNC_CONF :
|
||||
aconf = (ConfigItem_link *) ln.value.aconf;
|
||||
if (hp && aconf)
|
||||
bcopy(hp->h_addr, (char *)&aconf->ipnum,
|
||||
sizeof(struct IN_ADDR));
|
||||
break;
|
||||
case ASYNC_CONNECT :
|
||||
/* Async connect support, the only problem is we don't know who did the /connect
|
||||
* anymore, so we send the statusinfo to all local ops ;P -- Syzop
|
||||
*/
|
||||
aconf = (ConfigItem_link *) ln.value.aconf;
|
||||
if (hp && aconf)
|
||||
{
|
||||
int n;
|
||||
bcopy(hp->h_addr, (char *)&aconf->ipnum, sizeof(struct IN_ADDR));
|
||||
n = connect_server(aconf, (aClient *)NULL, hp);
|
||||
/* I love semi-duplicate code */
|
||||
switch(n) {
|
||||
case 0:
|
||||
sendto_realops("Connecting to %s[%s].", aconf->servername, aconf->hostname);
|
||||
break;
|
||||
case -1:
|
||||
sendto_realops("Couldn't connect to %s.", aconf->servername);
|
||||
break;
|
||||
case -2:
|
||||
/* Should not happen since hp is not NULL */
|
||||
sendto_realops("Hostname %s is unknown for server %s (!?).", aconf->hostname, aconf->servername);
|
||||
break;
|
||||
default:
|
||||
sendto_realops("Connection to %s failed: %s", aconf->servername, STRERROR(n));
|
||||
}
|
||||
}
|
||||
if (!hp) {
|
||||
sendto_realops("Hostname %s is unknown for server %s.", aconf->hostname, aconf->servername);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
break;
|
||||
}
|
||||
pkts++;
|
||||
#ifndef _WIN32
|
||||
if (ioctl(resfd, FIONREAD, &bytes) == -1)
|
||||
#else
|
||||
if (ioctlsocket(resfd, FIONREAD, &bytes) == -1)
|
||||
#endif
|
||||
bytes = 0;
|
||||
} while ((bytes > 0) && (pkts < 10));
|
||||
}
|
||||
|
||||
+1
-1
@@ -1619,7 +1619,7 @@ int init_conf(char *rootconf, int rehash)
|
||||
if (rehash)
|
||||
{
|
||||
Hook *h;
|
||||
del_async_connects();
|
||||
unrealdns_delasyncconnects();
|
||||
config_rehash();
|
||||
#ifndef STATIC_LINKING
|
||||
Unload_all_loaded_modules();
|
||||
|
||||
+8
-1
@@ -747,6 +747,13 @@ static void exit_one_client(aClient *cptr, aClient *sptr, aClient *from, char *c
|
||||
* that have this person on DCCALLOW that the user just left/got removed.
|
||||
*/
|
||||
remove_dcc_references(sptr);
|
||||
|
||||
/* For remote clients, we need to check for any outstanding async
|
||||
* connects attached to this 'sptr', and set those records to NULL.
|
||||
* Why not for local? Well, we already do that in close_connection ;)
|
||||
*/
|
||||
if (!MyConnect(sptr))
|
||||
unrealdns_delreq_bycptr(sptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -802,7 +809,7 @@ char text[2048];
|
||||
if (counted == IRCstats.operators)
|
||||
return;
|
||||
sprintf(text, "[BUG] operator count bug! value in /lusers is '%d', we counted '%d', "
|
||||
"user='%s', userserver='%s', tag=%s. Corrected. "
|
||||
"user='%s', userserver='%s', tag=%s. Corrected. ",
|
||||
IRCstats.operators, counted, orig->name ? orig->name : "<null>",
|
||||
orig->srvptr ? orig->srvptr->name : "<null>", tag ? tag : "<null>");
|
||||
#ifdef DEBUGMODE
|
||||
|
||||
+20
@@ -28,6 +28,7 @@ static char sccsid[] =
|
||||
#endif
|
||||
|
||||
#include "struct.h"
|
||||
#include "numeric.h"
|
||||
#include "common.h"
|
||||
#include "sys.h"
|
||||
#include "h.h"
|
||||
@@ -2123,6 +2124,10 @@ void sendto_message_one(aClient *to, aClient *from, char *sender,
|
||||
sender, cmd, nick, msg);
|
||||
}
|
||||
|
||||
/* sidenote: sendnotice() and sendtxtnumeric() assume no client or server
|
||||
* has a % in their nick, which is a safe assumption since % is illegal.
|
||||
*/
|
||||
|
||||
void sendnotice(aClient *to, char *pattern, ...)
|
||||
{
|
||||
static char realpattern[1024];
|
||||
@@ -2137,3 +2142,18 @@ va_list vl;
|
||||
vsendto_one(to, realpattern, vl);
|
||||
va_end(vl);
|
||||
}
|
||||
|
||||
void sendtxtnumeric(aClient *to, char *pattern, ...)
|
||||
{
|
||||
static char realpattern[1024];
|
||||
va_list vl;
|
||||
|
||||
if (!IsWebTV(to))
|
||||
ircsprintf(realpattern, ":%s %d %s :%s", me.name, RPL_TEXT, to->name, pattern);
|
||||
else
|
||||
ircsprintf(realpattern, ":%s PRIVMSG %s :%s", me.name, to->name, pattern);
|
||||
|
||||
va_start(vl, pattern);
|
||||
vsendto_one(to, realpattern, vl);
|
||||
va_end(vl);
|
||||
}
|
||||
|
||||
@@ -2307,6 +2307,39 @@ inet_pton6(const char *src, unsigned char *dst)
|
||||
}
|
||||
#endif /* !HAVE_INET_PTON */
|
||||
|
||||
/** Finds out if an address is IPv6, returns 1 if so, otherwise 0 */
|
||||
int isipv6(struct IN_ADDR *addr)
|
||||
{
|
||||
#ifndef INET6
|
||||
return 0;
|
||||
#else
|
||||
static char compareme[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff }; /* First part of IPv4-in-IPv6 (::ffff) */
|
||||
|
||||
/* If memcmp returns non-zero it means it did not match, hence it is ipv6, otherwise it is ipv4 */
|
||||
return memcmp(addr, compareme, 12) ? 1 : 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Transforms an IPv4 address (assumed in network byte order) to inet6 (as ::ffff:a.b.c.d). */
|
||||
void inet4_to_inet6(const void *src_in, void *dst_in)
|
||||
{
|
||||
char *dst = dst_in;
|
||||
const char *src = src_in;
|
||||
|
||||
memset(dst, 0, 10);
|
||||
dst[10] = 0xff;
|
||||
dst[11] = 0xff;
|
||||
memcpy(&dst[12], src, 4);
|
||||
}
|
||||
|
||||
/** Transforms an IPv4-in-IPv6 mapped address to IPv4 (so ::ffff:a.b.c.d to a.b.c.d),
|
||||
* both are (/will be) in NETWORK BYTE ORDER.
|
||||
*/
|
||||
void inet6_to_inet4(const void *src, void *dst)
|
||||
{
|
||||
memcpy(dst, (char *)src + 12, 4);
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Microsoft makes things nice and fun for us! */
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user