original files of m241
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
/*************************************************************************/
|
||||
/* (c) Copyright Tai Jin, 1988. All Rights Reserved. */
|
||||
/* Hewlett-Packard Laboratories. */
|
||||
/* */
|
||||
/* Permission is hereby granted for unlimited modification, use, and */
|
||||
/* distribution. This software is made available with no warranty of */
|
||||
/* any kind, express or implied. This copyright notice must remain */
|
||||
/* intact in all versions of this software. */
|
||||
/* */
|
||||
/* The author would appreciate it if any bug fixes and enhancements were */
|
||||
/* to be sent back to him for incorporation into future versions of this */
|
||||
/* software. Please send changes to tai@iag.hp.com or ken@sdd.hp.com. */
|
||||
/*************************************************************************/
|
||||
|
||||
/* "adjtime.h,v 3.1 1993/07/06 01:04:43 jbj Exp" */
|
||||
/* adjtime.h,v
|
||||
* Revision 3.1 1993/07/06 01:04:43 jbj
|
||||
* NTP release 3.1
|
||||
*
|
||||
*
|
||||
* Revision 1.5 90/02/07 15:34:18 15:34:18 src (Source Hacker)
|
||||
* CHANGED KEY !!!
|
||||
*
|
||||
* Revision 1.4 89/02/09 12:26:35 12:26:35 tai (Tai Jin (Guest))
|
||||
* *** empty log message ***
|
||||
*
|
||||
* Revision 1.4 89/02/09 12:26:35 12:26:35 tai (Tai Jin)
|
||||
* added comment
|
||||
*
|
||||
* Revision 1.3 88/08/30 01:08:29 01:08:29 tai (Tai Jin)
|
||||
* fix copyright notice again
|
||||
*
|
||||
* Revision 1.2 88/08/30 00:51:55 00:51:55 tai (Tai Jin)
|
||||
* fix copyright notice
|
||||
*
|
||||
* Revision 1.1 88/04/02 14:56:54 14:56:54 tai (Tai Jin)
|
||||
* Initial revision
|
||||
* */
|
||||
|
||||
#include "ntp_types.h"
|
||||
|
||||
#define KEY 659847L
|
||||
|
||||
typedef union {
|
||||
struct msgbuf msgp;
|
||||
struct {
|
||||
long mtype;
|
||||
int code;
|
||||
struct timeval tv;
|
||||
} msgb;
|
||||
} MsgBuf;
|
||||
|
||||
#define MSGSIZE (sizeof(int) + sizeof(struct timeval))
|
||||
/*
|
||||
* mtype values
|
||||
*/
|
||||
#define CLIENT 1L
|
||||
#define SERVER 2L
|
||||
/*
|
||||
* code values
|
||||
*/
|
||||
#define DELTA1 0
|
||||
#define DELTA2 1
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* /src/NTP/ntp4-dev/include/ascii.h,v 4.4 2005/04/16 17:32:10 kardel RELEASE_20050508_A
|
||||
*
|
||||
* ascii.h,v 4.4 2005/04/16 17:32:10 kardel RELEASE_20050508_A
|
||||
*
|
||||
* $Created: Sun Jul 20 11:42:53 1997 $
|
||||
*
|
||||
* Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the author 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 AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef ASCII_H
|
||||
#define ASCII_H
|
||||
|
||||
/*
|
||||
* just name the common ASCII control codes
|
||||
*/
|
||||
#define NUL 0
|
||||
#define SOH 1
|
||||
#define STX 2
|
||||
#define ETX 3
|
||||
#define EOT 4
|
||||
#define ENQ 5
|
||||
#define ACK 6
|
||||
#define BEL 7
|
||||
#define BS 8
|
||||
#define HT 9
|
||||
#define NL 10
|
||||
#define VT 11
|
||||
#define NP 12
|
||||
#define CR 13
|
||||
#define SO 14
|
||||
#define SI 15
|
||||
#define DLE 16
|
||||
#define DC1 17
|
||||
#define DC2 18
|
||||
#define DC3 19
|
||||
#define DC4 20
|
||||
#define NAK 21
|
||||
#define SYN 22
|
||||
#define ETB 23
|
||||
#define CAN 24
|
||||
#define EM 25
|
||||
#define SUB 26
|
||||
#define ESC 27
|
||||
#define FS 28
|
||||
#define GS 29
|
||||
#define RS 30
|
||||
#define US 31
|
||||
#define SP 32
|
||||
#define DEL 127
|
||||
|
||||
#endif
|
||||
/*
|
||||
* History:
|
||||
*
|
||||
* ascii.h,v
|
||||
* Revision 4.4 2005/04/16 17:32:10 kardel
|
||||
* update copyright
|
||||
*
|
||||
* Revision 4.3 2004/11/14 15:29:41 kardel
|
||||
* support PPSAPI, upgrade Copyright to Berkeley style
|
||||
*
|
||||
* Revision 4.1 1998/07/11 10:05:22 kardel
|
||||
* Release 4.0.73d reconcilation
|
||||
*
|
||||
* Revision 4.0 1998/04/10 19:50:38 kardel
|
||||
* Start 4.0 release version numbering
|
||||
*
|
||||
* Revision 4.0 1998/04/10 19:50:38 kardel
|
||||
* Start 4.0 release version numbering
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Header file for audio drivers
|
||||
*/
|
||||
#ifndef NTP_AUDIO_H
|
||||
#define NTP_AUDIO_H
|
||||
#include "ntp_types.h"
|
||||
|
||||
#define MAXGAIN 255 /* max codec gain */
|
||||
#define MONGAIN 127 /* codec monitor gain */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
int audio_init (const char *, int, int);
|
||||
int audio_gain (int, int, int);
|
||||
void audio_show (void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* /src/NTP/ntp4-dev/include/binio.h,v 4.5 2005/04/16 17:32:10 kardel RELEASE_20050508_A
|
||||
*
|
||||
* binio.h,v 4.5 2005/04/16 17:32:10 kardel RELEASE_20050508_A
|
||||
*
|
||||
* $Created: Sun Jul 20 13:03:05 1997 $
|
||||
*
|
||||
* Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the author 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 AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef BINIO_H
|
||||
#define BINIO_H
|
||||
|
||||
#include "ntp_stdlib.h"
|
||||
|
||||
long get_lsb_short (unsigned char **);
|
||||
void put_lsb_short (unsigned char **, long);
|
||||
long get_lsb_long (unsigned char **);
|
||||
void put_lsb_long (unsigned char **, long);
|
||||
|
||||
#define get_lsb_int16( _x_ ) ((int16_t) get_lsb_short( _x_ ))
|
||||
#define get_lsb_uint16( _x_ ) ((uint16_t) get_lsb_short( _x_ ))
|
||||
#define get_lsb_int32( _x_ ) ((int32_t) get_lsb_long( _x_ ))
|
||||
#define get_lsb_uint32( _x_ ) ((uint32_t) get_lsb_long( _x_ ))
|
||||
|
||||
long get_msb_short (unsigned char **);
|
||||
void put_msb_short (unsigned char **, long);
|
||||
long get_msb_long (unsigned char **);
|
||||
void put_msb_long (unsigned char **, long);
|
||||
|
||||
#define get_msb_int16( _x_ ) ((int16_t) get_msb_short( _x_ ))
|
||||
#define get_msb_uint16( _x_ ) ((uint16_t) get_msb_short( _x_ ))
|
||||
#define get_msb_int32( _x_ ) ((int32_t) get_msb_long( _x_ ))
|
||||
#define get_msb_uint32( _x_ ) ((uint32_t) get_msb_long( _x_ ))
|
||||
|
||||
#endif
|
||||
/*
|
||||
* History:
|
||||
*
|
||||
* binio.h,v
|
||||
* Revision 4.5 2005/04/16 17:32:10 kardel
|
||||
* update copyright
|
||||
*
|
||||
* Revision 4.4 2004/11/14 15:29:41 kardel
|
||||
* support PPSAPI, upgrade Copyright to Berkeley style
|
||||
*
|
||||
* Revision 4.2 1998/06/28 16:52:15 kardel
|
||||
* added binio MSB prototypes for {get,put}_msb_{short,long}
|
||||
*
|
||||
* Revision 4.1 1998/06/12 15:07:40 kardel
|
||||
* fixed prototyping
|
||||
*
|
||||
* Revision 4.0 1998/04/10 19:50:38 kardel
|
||||
* Start 4.0 release version numbering
|
||||
*
|
||||
* Revision 1.1 1998/04/10 19:27:32 kardel
|
||||
* initial NTP VERSION 4 integration of PARSE with GPS166 binary support
|
||||
*
|
||||
* Revision 1.1 1997/10/06 20:55:37 kardel
|
||||
* new parse structure
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* declcond.h - declarations conditionalized for ntpd
|
||||
*
|
||||
* The NTP reference implementation distribution includes two distinct
|
||||
* declcond.h files, one in ntpd/ used only by ntpd, and another in
|
||||
* include/ used by libntp and utilities. This relies on the source
|
||||
* file's directory being ahead of include/ in the include search.
|
||||
*
|
||||
* The ntpd variant of declcond.h declares "debug" only #ifdef DEBUG,
|
||||
* as the --disable-debugging version of ntpd should not reference
|
||||
* "debug". The libntp and utilities variant always declares debug,
|
||||
* as it is used in those codebases even without DEBUG defined.
|
||||
*/
|
||||
#ifndef DECLCOND_H
|
||||
#define DECLCOND_H
|
||||
|
||||
/* #ifdef DEBUG */ /* uncommented in ntpd/declcond.h */
|
||||
extern int debug;
|
||||
/* #endif */ /* uncommented in ntpd/declcond.h */
|
||||
|
||||
#endif /* DECLCOND_H */
|
||||
@@ -0,0 +1,57 @@
|
||||
/****************************************************************************/
|
||||
/* gps.h */
|
||||
/* TrueTime GPS-VME and VME-SG */
|
||||
/* VME controller hardware commands and parameters. */
|
||||
/* created 010694 res */
|
||||
/* History: revised for 747i 3/94 */
|
||||
/****************************************************************************/
|
||||
#ifndef NTP_GPS_H
|
||||
#define NTP_GPS_H
|
||||
|
||||
|
||||
#define GPS_VME "/dev/vme2" /* the device file for the GPS board */
|
||||
/* change it to whatever yours is */
|
||||
#define PRIO 120 /* set the realtime priority */
|
||||
#define NREGS 7 /* number of registers we will use */
|
||||
|
||||
#define GFRZ1 0x0020 /* freeze cmd addr gen reg. 1 */
|
||||
#define GREG1A 0x0021 /* Gen reg. 1 Word A (units microsec to 0.001 sec) */
|
||||
#define GREG1B 0x0040 /* Gen reg. 1 Word B (units 0.01 sec to tens sec ) */
|
||||
#define GREG1C 0x0041 /* Gen reg 1 Word C (units mins and hours) */
|
||||
#define GREG1D 0x0042 /* Gen reg. 1 Word D (units days and status) */
|
||||
#define GREG1E 0x0043 /* Gen reg. 1 Word E (units Years ) */
|
||||
#define GUFRZ1 0x0022 /* unfreeze cmd addr gen reg 1 */
|
||||
|
||||
#define MASKDAY 0x0FFF /* mask for units days */
|
||||
#define MASKHI 0xFF00
|
||||
#define MASKLO 0x00FF
|
||||
/* Use the following ASCII hex values: N(0x004e),S(0x0053),E(0x0045),
|
||||
W(0x0057), +(0x002B), - (0x002D) */
|
||||
|
||||
#define LAT1 0x0048 /* Lat (degrees) */
|
||||
#define LAT2 0x0049 /* Lat (min, sec) */
|
||||
#define LAT3 0x004A /* Lat (N/S, tenths sec) */
|
||||
#define LON1 0x004B /* Lon (degrees) */
|
||||
#define LON2 0x004C /* Lon (min, sec) */
|
||||
#define LON3 0x004D /* Lon (E/W, tenths sec) */
|
||||
#define ELV1 0x004E /* Elev. (sign, 10,000 and 1000 ) */
|
||||
#define ELV2 0x004F /* Elev. (100, 10s, units, and .1) */
|
||||
|
||||
#define CFREG1 0x0050 /* config. register 1 */
|
||||
#define CFREG2 0x00A0 /* config. register 2 */
|
||||
#define PMODE 0x00A4 /* Position mode */
|
||||
#define LOCAL 0x0051 /* Local hours offset */
|
||||
#define RATE 0x0054 /* Pulse rate output select */
|
||||
#define DAC 0x0055 /* OSC Control (DAC) select */
|
||||
|
||||
#define PUMS 0x0056 /* Gen. preset register unit millisec */
|
||||
#define PMS 0x0057 /* Gen. preset register units hundreds and tens ms */
|
||||
#define PSEC 0x0058 /* Gen. preset register units tens and unit seconds */
|
||||
#define PMIN 0x0059 /* Gen. preset register units tens and unit minutes */
|
||||
#define PHRS 0x005A /* Gen. preset register units tens and unit hours */
|
||||
#define PDYS1 0x005B /* Gen. preset register units tens and unit days */
|
||||
#define PDYS2 0x005C /* Gen. preset register units hundreds days */
|
||||
#define PYRS1 0x005D /* Gen. preset register units tens and unit years */
|
||||
#define PYRS2 0x005E /* Gen. preset reg. units thousands and hundreds yrs */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,144 @@
|
||||
/****************************************************************************/
|
||||
/* hopf6039.h */
|
||||
/* hopf Elektronik 6039 PCI radio clock header */
|
||||
/* (c) 1999, 2000 Bernd Altmeier <altmeier@ATLSoft.de> */
|
||||
/* Rev. 1.00 Date 25.03.2000 */
|
||||
/* History: */
|
||||
/****************************************************************************/
|
||||
|
||||
#ifndef _hopf6039_H_
|
||||
#define _hopf6039_H_
|
||||
|
||||
#define HOPF_MAXVERSION 8
|
||||
#define HOPF_CNTR_MEM_LEN 0x7f
|
||||
#define HOPF_DATA_MEM_LEN 0x3ff /* this is our memory size */
|
||||
|
||||
/* macros and definition for 32 to 16 to 8 bit conversion */
|
||||
|
||||
typedef unsigned long DWORD;
|
||||
typedef unsigned char BYTE;
|
||||
typedef unsigned short WORD;
|
||||
|
||||
#define LOWORD(l) ((WORD)(l))
|
||||
#define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))
|
||||
#define LOBYTE(w) ((BYTE)(w))
|
||||
#define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))
|
||||
|
||||
/* iocntl codes for driver access */
|
||||
|
||||
#define HOPF_CLOCK_CMD_MASK 0xff000
|
||||
|
||||
#define HOPF_CLOCK_GET_LOCAL 0x10000
|
||||
#define HOPF_CLOCK_GET_UTC 0x20000
|
||||
#define HOPF_CLOCK_GET_ANTENNA 0x30000
|
||||
#define HOPF_CLOCK_GET_DIFFERENCE 0x40000
|
||||
#define HOPF_CLOCK_GET_VERSION 0x50000
|
||||
#define HOPF_CLOCK_GET_POSITION 0x60000
|
||||
#define HOPF_CLOCK_GET_SATDATA 0x70000
|
||||
#define HOPF_CLOCK_GET_SYSTEMBYTE 0x80000
|
||||
#define HOPF_CLOCK_GET_IRIG 0x90000
|
||||
|
||||
#define HOPF_CLOCK_SET_DIFFERENCE 0x01000
|
||||
#define HOPF_CLOCK_SET_ANTENNA 0x02000
|
||||
#define HOPF_CLOCK_SET_TIME 0x03000
|
||||
#define HOPF_CLOCK_SET_POSITION 0x04000
|
||||
#define HOPF_CLOCK_SET_SATMODE 0x05000
|
||||
#define HOPF_CLOCK_SET_SYSTEMBYTE 0x06000
|
||||
#define HOPF_CLOCK_SET_RESET 0x07000
|
||||
#define HOPF_CLOCK_SET_IRIG 0x08000
|
||||
|
||||
/* clock command codes */
|
||||
|
||||
#define HOPF_CLOCK_HARDRESET 0x00008000
|
||||
#define HOPF_CLOCK_SOFTRESET 0x00004000
|
||||
|
||||
/* sat-information */
|
||||
|
||||
typedef struct SatStat{
|
||||
BYTE wVisible;
|
||||
BYTE wMode;
|
||||
BYTE wSat0;
|
||||
BYTE wRat0;
|
||||
BYTE wSat1;
|
||||
BYTE wRat1;
|
||||
BYTE wSat2;
|
||||
BYTE wRat2;
|
||||
BYTE wSat3;
|
||||
BYTE wRat3;
|
||||
BYTE wSat4;
|
||||
BYTE wRat4;
|
||||
BYTE wSat5;
|
||||
BYTE wRat5;
|
||||
BYTE wSat6;
|
||||
BYTE wRat6;
|
||||
BYTE wSat7;
|
||||
BYTE wRat7;
|
||||
} SatStat;
|
||||
|
||||
/* GPS position */
|
||||
|
||||
typedef struct GPSPos { /* Position */
|
||||
long wAltitude;
|
||||
long wLongitude;
|
||||
long wLatitude;
|
||||
} GPSPos;
|
||||
|
||||
/* clock hardware version */
|
||||
|
||||
typedef struct ClockVersion {
|
||||
char cVersion[255]; /* Hardware Version like " DCF-RECEIVER, VERSION 01.01, DAT: 23.NOV.1999" */
|
||||
char dVersion[255]; /* Driver Version */
|
||||
} ClockVersion;
|
||||
|
||||
/* hopftime what you think */
|
||||
|
||||
typedef struct HOPFTIME {
|
||||
unsigned int wYear;
|
||||
unsigned int wMonth;
|
||||
unsigned int wDayOfWeek;
|
||||
unsigned int wDay;
|
||||
unsigned int wHour;
|
||||
unsigned int wMinute;
|
||||
unsigned int wSecond;
|
||||
unsigned int wMilliseconds;
|
||||
unsigned int wStatus;
|
||||
} HOPFTIME;
|
||||
|
||||
/* DCF77 antenna alignment */
|
||||
|
||||
typedef struct DcfAntenne {
|
||||
BYTE bStatus;
|
||||
BYTE bStatus1;
|
||||
WORD wAntValue;
|
||||
} DcfAntenne;
|
||||
|
||||
/* hopf PCI clock */
|
||||
|
||||
typedef struct hopfCard {
|
||||
char name[32];
|
||||
unsigned irq;
|
||||
unsigned long membase; /* without mmap */
|
||||
unsigned int port;
|
||||
|
||||
int versionlen;
|
||||
char versionbuf[1024];
|
||||
char *version[HOPF_MAXVERSION];
|
||||
char cardname[32];
|
||||
int interrupt;
|
||||
void *mbase; /* this will be our memory base address */
|
||||
|
||||
} hopfCard;
|
||||
|
||||
typedef struct cardparams {
|
||||
unsigned int port;
|
||||
unsigned irq;
|
||||
int cardtype;
|
||||
int cardnr;
|
||||
unsigned int membase;
|
||||
} cardparams;
|
||||
|
||||
|
||||
#define WRITE_REGISTER 0x00
|
||||
#define READ_REGISTER 0x01
|
||||
|
||||
#endif /* _hopf6039_H_ */
|
||||
@@ -0,0 +1,101 @@
|
||||
#ifndef NTP_ICOM_H
|
||||
#define NTP_ICOM_H
|
||||
|
||||
/*
|
||||
* Header file for ICOM radios
|
||||
*/
|
||||
#include "ntp_types.h"
|
||||
|
||||
/*
|
||||
* Common definitions
|
||||
*/
|
||||
#define P_ERMSG 0x1 /* trace bus error messages */
|
||||
#define P_TRACE 0x2 /* trace CI-V messges */
|
||||
#define RETRY 3 /* max packet retries */
|
||||
#define IBAUD B1200 /* autotune port speed */
|
||||
|
||||
/*
|
||||
* Radio identifier codes
|
||||
*/
|
||||
#define IC1271 0x24
|
||||
#define IC1275 0x18
|
||||
#define IC271 0x20
|
||||
#define IC275 0x10
|
||||
#define IC375 0x12
|
||||
#define IC471 0x22
|
||||
#define IC475 0x14
|
||||
#define IC575 0x16
|
||||
#define IC725 0x28
|
||||
#define IC726 0x30
|
||||
#define IC735 0x04
|
||||
#define IC751 0x1c
|
||||
#define IC761 0x1e
|
||||
#define IC765 0x2c
|
||||
#define IC775 0x46
|
||||
#define IC781 0x26
|
||||
#define IC970 0x2e
|
||||
#define R7000 0x08
|
||||
#define R71 0x1a
|
||||
#define R7100 0x34
|
||||
#define R72 0x32
|
||||
#define R8500 0x4a
|
||||
#define R9000 0x2a
|
||||
|
||||
/*
|
||||
* CI-V frame codes
|
||||
*/
|
||||
#define PR 0xfe /* preamble */
|
||||
#define TX 0xe0 /* controller address */
|
||||
#define FI 0xfd /* end of message */
|
||||
#define ACK 0xfb /* controller normal reply */
|
||||
#define NAK 0xfa /* controller error reply */
|
||||
#define PAD 0xff /* transmit padding */
|
||||
|
||||
/*
|
||||
* CI-V controller commands
|
||||
*/
|
||||
#define V_FREQT 0x00 /* freq set (transceive) */
|
||||
#define V_MODET 0x01 /* set mode (transceive) */
|
||||
#define V_RBAND 0x02 /* read band edge */
|
||||
#define V_RFREQ 0x03 /* read frequency */
|
||||
#define V_RMODE 0x04 /* read mode */
|
||||
#define V_SFREQ 0x05 /* set frequency */
|
||||
#define V_SMODE 0x06 /* set mode */
|
||||
#define V_SVFO 0x07 /* select vfo */
|
||||
#define V_SMEM 0x08 /* select channel/bank */
|
||||
#define V_WRITE 0x09 /* write channel */
|
||||
#define V_VFOM 0x0a /* memory -> vfo */
|
||||
#define V_CLEAR 0x0b /* clear channel */
|
||||
#define V_ROFFS 0x0c /* read tx offset */
|
||||
#define V_SOFFS 0x0d /* write tx offset */
|
||||
#define V_SCAN 0x0e /* scan control */
|
||||
#define V_SPLIT 0x0f /* split control */
|
||||
#define V_DIAL 0x10 /* set dial tuning step */
|
||||
#define V_ATTEN 0x11 /* set attenuator */
|
||||
#define V_SANT 0x12 /* select antenna */
|
||||
#define V_ANNC 0x13 /* announce control */
|
||||
#define V_WRCTL 0x14 /* write controls */
|
||||
#define V_RDCTL 0x15 /* read controls */
|
||||
#define V_TOGL 0x16 /* set switches */
|
||||
#define V_ASCII 0x17 /* send CW message */
|
||||
#define V_POWER 0x18 /* power control */
|
||||
#define V_RDID 0x19 /* read model ID */
|
||||
#define V_SETW 0x1a /* read/write channel/bank data */
|
||||
#define V_CTRL 0x7f /* miscellaneous control */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
int icom_init (const char *, int, int);
|
||||
int icom_freq (int, int, double);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* /src/NTP/ntp4-dev/include/ieee754io.h,v 4.3 2005/04/16 17:32:10 kardel RELEASE_20050508_A
|
||||
*
|
||||
* ieee754io.h,v 4.3 2005/04/16 17:32:10 kardel RELEASE_20050508_A
|
||||
*
|
||||
* $Created: Sun Jul 13 12:22:11 1997 $
|
||||
*
|
||||
* Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the author 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 AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef IEEE754IO_H
|
||||
#define IEEE754IO_H
|
||||
|
||||
#define IEEE_SINGLE 1
|
||||
#define IEEE_DOUBLE 2
|
||||
|
||||
#define IEEE_MSB 1
|
||||
#define IEEE_LSB 2
|
||||
|
||||
#define IEEE_OK 0 /* conversion ok */
|
||||
#define IEEE_BADCALL 1 /* bad call parameters */
|
||||
#define IEEE_NAN 2 /* found an NaN */
|
||||
#define IEEE_POSINFINITY 3 /* positive infinity */
|
||||
#define IEEE_NEGINFINITY 4 /* negative infinity */
|
||||
#define IEEE_POSOVERFLOW 5 /* positive overflow */
|
||||
#define IEEE_NEGOVERFLOW 6 /* negative overflow */
|
||||
|
||||
#define IEEE_OFFSETS 8 /* number of byte positions */
|
||||
typedef unsigned char offsets_t[IEEE_OFFSETS];
|
||||
|
||||
int fetch_ieee754 (unsigned char **bufp, int size, l_fp *lfpp, offsets_t offsets);
|
||||
int put_ieee754 (unsigned char **bufpp, int size, l_fp *lfpp, offsets_t offsets);
|
||||
|
||||
#endif
|
||||
/*
|
||||
* History:
|
||||
*
|
||||
* ieee754io.h,v
|
||||
* Revision 4.3 2005/04/16 17:32:10 kardel
|
||||
* update copyright
|
||||
*
|
||||
* Revision 4.2 2004/11/14 15:29:41 kardel
|
||||
* support PPSAPI, upgrade Copyright to Berkeley style
|
||||
*
|
||||
* Revision 4.0 1998/04/10 19:50:40 kardel
|
||||
* Start 4.0 release version numbering
|
||||
*
|
||||
* Revision 1.1 1998/04/10 19:27:33 kardel
|
||||
* initial NTP VERSION 4 integration of PARSE with GPS166 binary support
|
||||
*
|
||||
* Revision 1.1 1997/10/06 20:55:37 kardel
|
||||
* new parse structure
|
||||
*
|
||||
*/
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* intreswork.h -- declarations private to ntp_intres.c, ntp_worker.c.
|
||||
*/
|
||||
#ifndef INTRESWORK_H
|
||||
#define INTRESWORK_H
|
||||
|
||||
#include "ntp_worker.h"
|
||||
|
||||
#ifdef WORKER
|
||||
|
||||
extern int blocking_getaddrinfo(blocking_child *,
|
||||
blocking_pipe_header *);
|
||||
extern int blocking_getnameinfo(blocking_child *,
|
||||
blocking_pipe_header *);
|
||||
|
||||
#ifdef TEST_BLOCKING_WORKER
|
||||
extern void gai_test_callback(int rescode, int gai_errno,
|
||||
void *context, const char *name,
|
||||
const char *service,
|
||||
const struct addrinfo *hints,
|
||||
const struct addrinfo *ai_res);
|
||||
extern void gni_test_callback(int rescode, int gni_errno,
|
||||
sockaddr_u *psau, int flags,
|
||||
const char *host,
|
||||
const char *service, void *context);
|
||||
#endif /* TEST_BLOCKING_WORKER */
|
||||
#endif /* WORKER */
|
||||
|
||||
#endif /* INTRESWORK_H */
|
||||
@@ -0,0 +1,63 @@
|
||||
#ifndef IOSIGNAL_H
|
||||
#define IOSIGNAL_H
|
||||
|
||||
#include "ntp_refclock.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
/*
|
||||
* Some systems (MOST) define SIGPOLL == SIGIO, others SIGIO == SIGPOLL, and
|
||||
* a few have separate SIGIO and SIGPOLL signals. This code checks for the
|
||||
* SIGIO == SIGPOLL case at compile time.
|
||||
* Do not define USE_SIGPOLL or USE_SIGIO.
|
||||
* these are interal only to iosignal.c and ntpd/work_fork.c!
|
||||
*/
|
||||
#if defined(USE_SIGPOLL)
|
||||
# undef USE_SIGPOLL
|
||||
#endif
|
||||
#if defined(USE_SIGIO)
|
||||
# undef USE_SIGIO
|
||||
#endif
|
||||
|
||||
/* type of input handler function - only shared between iosignal.c and ntp_io.c */
|
||||
typedef void (input_handler_t)(l_fp *);
|
||||
|
||||
#if defined(HAVE_SIGNALED_IO)
|
||||
# if defined(USE_TTY_SIGPOLL) || defined(USE_UDP_SIGPOLL)
|
||||
# define USE_SIGPOLL
|
||||
# endif
|
||||
|
||||
# if !defined(USE_TTY_SIGPOLL) || !defined(USE_UDP_SIGPOLL)
|
||||
# define USE_SIGIO
|
||||
# endif
|
||||
|
||||
# if defined(USE_SIGIO) && defined(USE_SIGPOLL)
|
||||
# if SIGIO == SIGPOLL
|
||||
# define USE_SIGIO
|
||||
# undef USE_SIGPOLL
|
||||
# endif /* SIGIO == SIGPOLL */
|
||||
# endif /* USE_SIGIO && USE_SIGPOLL */
|
||||
|
||||
#define USING_SIGIO() using_sigio
|
||||
|
||||
extern int using_sigio;
|
||||
|
||||
extern void block_sigio (void);
|
||||
extern void unblock_sigio (void);
|
||||
extern int init_clock_sig (struct refclockio *);
|
||||
extern void init_socket_sig (int);
|
||||
extern void set_signal (input_handler_t *);
|
||||
|
||||
# define BLOCKIO() block_sigio()
|
||||
# define UNBLOCKIO() unblock_sigio()
|
||||
|
||||
#else /* !HAVE_SIGNALED_IO follows */
|
||||
# define BLOCKIO() do {} while (0)
|
||||
# define UNBLOCKIO() do {} while (0)
|
||||
# define USING_SIGIO() FALSE
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* IOSIGNAL_H */
|
||||
@@ -0,0 +1,317 @@
|
||||
/* ipntp.h - Wind River NTP library */
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
* INTERPEAK API HEADER FILE
|
||||
*
|
||||
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipntp.h,v $ $Revision: 1.3.10.6 $
|
||||
* $Source: /home/interpeak/CVSRoot/ipntp/include/ipntp.h,v $
|
||||
* $Author: jren $ $Date: 2015-12-17 09:21:37 $
|
||||
* $State: Exp $ $Locker: $
|
||||
*
|
||||
* INTERPEAK_COPYRIGHT_STRING
|
||||
* Design and implementation by Windriver
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef IPNTP_H
|
||||
#define IPNTP_H
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 1 DESCRIPTION
|
||||
****************************************************************************
|
||||
* Public header file of NTP.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
This library contains the APIs provided by the WindRiver NTP.
|
||||
INCLUDE FILES: ipcom_type.h, ipcom_time.h
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 2 CONFIGURATION
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 3 INCLUDE FILES
|
||||
****************************************************************************
|
||||
*/
|
||||
#include <ipcom_type.h>
|
||||
#include <ipcom_time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 4 DEFINES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
#define IPNTP_MAX_NAME 256
|
||||
#define IPNTP_MAX_HOSTNAME 512
|
||||
#define IPNTP_MAX_PASSWORD 256
|
||||
#define IPNTP_PRIVATE_CERT_TYPE 1
|
||||
#define IPNTP_TRUSTED_CERT_TYPE 2
|
||||
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* release
|
||||
*===========================================================================
|
||||
*/
|
||||
|
||||
#define IPNTP_RELEASE 60600
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 5 TYPES
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
typedef struct Ipntp_key_param_struct
|
||||
{
|
||||
char rndfile[IPNTP_MAX_NAME]; /* The rand filename */
|
||||
char local_passwd[IPNTP_MAX_PASSWORD]; /* local private password */
|
||||
char export_passwd[IPNTP_MAX_PASSWORD]; /* export IFF or GQ group keys with password */
|
||||
char group_name[IPNTP_MAX_HOSTNAME]; /* The group name */
|
||||
char subject_name[IPNTP_MAX_NAME]; /* The subject name */
|
||||
char certificate[IPNTP_MAX_NAME]; /* The certificate scheme */
|
||||
char cipher[IPNTP_MAX_NAME]; /* The privatekey cipher */
|
||||
char signkey[8]; /* generate sign key with RSA or DSA */
|
||||
int imbits; /* identity modulus bits, must be 256 to 2048 */
|
||||
int modulus; /* modulus, must be 256 to 2048 */
|
||||
int md5key; /* generate MD5 keys */
|
||||
int iffpar; /* generate IFF parameters */
|
||||
int gqpar; /* generate GQ parameters */
|
||||
int mvkey; /* generate MV parameters and the number of MV parameters */
|
||||
int update_mvkey; /* Update MV keys */
|
||||
int writekey; /* Write IFF or GQ identity keys */
|
||||
int hostkey; /* generate host key with RSA-MD5 */
|
||||
int certtype; /* generated cert type, PC private cert or trusted cert (TC scheme) */
|
||||
int lifetime; /* set certificate lifetime */
|
||||
}
|
||||
Ipntp_key_param;
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* 6 FUNCTIONS
|
||||
****************************************************************************
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipntp_changetime - change the current target time
|
||||
*
|
||||
* This function changes the target time with <offset> seconds added.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <offset>
|
||||
* offset.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:\is
|
||||
* \i 'IPCOM_SUCCESS', or one of the following errors:
|
||||
* \i 'IPCOM_ERR_FAILED'
|
||||
* General error.
|
||||
* \ie
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipntp_changetime(
|
||||
int offset
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipntp_timediff - get the timediff between (S)NTP server and the target
|
||||
*
|
||||
* This function gets the time of the target and query the time of (S)NTP server.
|
||||
* Then comparte the difference between them.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <pServerAddr>
|
||||
* Host name or Internet address of the (S)NTP server.
|
||||
* \i <timeout>
|
||||
* Timeout in seconds. Specifies how long the function will wait for a response.
|
||||
* '-1' means that there is no timeout; the routine can wait forever.
|
||||
* \i <diff>
|
||||
* Pointer to time difference in seconds between the target and the server.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:\is
|
||||
* \i 'IPCOM_SUCCESS', or one of the following errors:
|
||||
* \i 'IPCOM_TIMEOUT'
|
||||
* No response within the timeout period.
|
||||
* \i 'IPCOM_ERR_INVALID_ARG'
|
||||
* Invalid argument.
|
||||
* \i 'IPCOM_ERR_SOCKCALLFAILED'
|
||||
* A socket call failed.
|
||||
* \i 'IPCOM_ERR_NO_MEMORY'
|
||||
* Memory error.
|
||||
* \i 'IPCOM_ERR_FAILED'
|
||||
* General error.
|
||||
* \ie
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipntp_timediff(
|
||||
char * pServerAddr,
|
||||
Ip_s32 timeout,
|
||||
double *diff
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipntp_updatetime - read time from specified NTP server and update local time
|
||||
*
|
||||
* This routine reads time from specified NTP server and update local time.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <pServerAddr>
|
||||
* Host name or Internet address of the (S)NTP server.
|
||||
* \i <timeout>
|
||||
* Timeout in seconds. Specifies how long the function will wait for a response.
|
||||
* '-1' means that there is no timeout; the routine can wait forever.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:\is
|
||||
* \i 'IPCOM_SUCCESS', or one of the following errors:
|
||||
* \i 'IPCOM_TIMEOUT'
|
||||
* No response within the timeout period.
|
||||
* \i 'IPCOM_ERR_INVALID_ARG'
|
||||
* Invalid argument.
|
||||
* \i 'IPCOM_ERR_SOCKCALLFAILED'
|
||||
* A socket call failed.
|
||||
* \i 'IPCOM_ERR_NO_MEMORY'
|
||||
* Memory error.
|
||||
* \i 'IPCOM_ERR_FAILED'
|
||||
* General error.
|
||||
* \ie
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipntp_updatetime(
|
||||
char * pServerAddr,
|
||||
Ip_s32 timeout
|
||||
);
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipntp_querytime - read time from specified NTP server
|
||||
*
|
||||
* This routine reads time from specified NTP server.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <pServerAddr>
|
||||
* Host name or Internet address of the (S)NTP server.
|
||||
* \i <timeout>
|
||||
* Timeout in seconds. Specifies how long the function will wait for a response.
|
||||
* '-1' means that there is no timeout; the routine can wait forever.
|
||||
* \i <tv>
|
||||
* Pointer to an <Ip_timeval> structure for receiving the time returned. The
|
||||
* definition of the <Ip_timeval> structure is:
|
||||
* \cs
|
||||
* struct Ip_timeval
|
||||
* {
|
||||
* long tv_sec; /@ Seconds. @/
|
||||
* long tv_usec; /@ Microseconds. @/
|
||||
* };
|
||||
* \ce
|
||||
*
|
||||
* The value returned is relative to January 1, 1970. It can be used to update
|
||||
* the system\'s local clock.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:\is
|
||||
* \i 'IPCOM_SUCCESS', or one of the following errors:
|
||||
* \i 'IPCOM_TIMEOUT'
|
||||
* No response within the timeout period.
|
||||
* \i 'IPCOM_ERR_INVALID_ARG'
|
||||
* Invalid argument.
|
||||
* \i 'IPCOM_ERR_SOCKCALLFAILED'
|
||||
* A socket call failed.
|
||||
* \i 'IPCOM_ERR_NO_MEMORY'
|
||||
* Memory error.
|
||||
* \i 'IPCOM_ERR_FAILED'
|
||||
* General error.
|
||||
* \ie
|
||||
*
|
||||
* ERRNO:
|
||||
*/
|
||||
IP_PUBLIC Ip_err ipntp_querytime(
|
||||
char * pServerAddr,
|
||||
Ip_s32 timeout,
|
||||
struct Ip_timeval *tv
|
||||
);
|
||||
|
||||
#ifdef AUTOKEY
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ipntp_keygen - generates cryptographic data files used by the NTPv4 authentication and identification schemes.
|
||||
*
|
||||
* This routine generates cryptographic data files used by the NTPv4 authentication
|
||||
* and identification schemes.
|
||||
*
|
||||
* Parameters:
|
||||
* \is
|
||||
* \i <pathfilename>
|
||||
* The rand filename with path which will be used.
|
||||
* \ie
|
||||
*
|
||||
* RETURNS:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_PUBLIC void ipntp_keygen(char *pathfilename);
|
||||
#endif
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipntp_exit_callback
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL void ipntp_exit_callback(Ip_pid_t pid);
|
||||
|
||||
/*
|
||||
*===========================================================================
|
||||
* ipntp_getOptServ
|
||||
*===========================================================================
|
||||
* Description:
|
||||
* Parameters:
|
||||
* Returns:
|
||||
*
|
||||
* \NOMANUAL
|
||||
*/
|
||||
IP_GLOBAL Ip_err ipntp_getOptServ(char * ParamString, const char * progName, int *argc, char *argvloc[], int argvlen);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
****************************************************************************
|
||||
* END OF FILE
|
||||
****************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,375 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: app.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_APP_H
|
||||
#define ISC_APP_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/app.h
|
||||
* \brief ISC Application Support
|
||||
*
|
||||
* Dealing with program termination can be difficult, especially in a
|
||||
* multithreaded program. The routines in this module help coordinate
|
||||
* the shutdown process. They are used as follows by the initial (main)
|
||||
* thread of the application:
|
||||
*
|
||||
*\li isc_app_start(); Call very early in main(), before
|
||||
* any other threads have been created.
|
||||
*
|
||||
*\li isc_app_run(); This will post any on-run events,
|
||||
* and then block until application
|
||||
* shutdown is requested. A shutdown
|
||||
* request is made by calling
|
||||
* isc_app_shutdown(), or by sending
|
||||
* SIGINT or SIGTERM to the process.
|
||||
* After isc_app_run() returns, the
|
||||
* application should shutdown itself.
|
||||
*
|
||||
*\li isc_app_finish(); Call very late in main().
|
||||
*
|
||||
* Applications that want to use SIGHUP/isc_app_reload() to trigger reloading
|
||||
* should check the result of isc_app_run() and call the reload routine if
|
||||
* the result is ISC_R_RELOAD. They should then call isc_app_run() again
|
||||
* to resume waiting for reload or termination.
|
||||
*
|
||||
* Use of this module is not required. In particular, isc_app_start() is
|
||||
* NOT an ISC library initialization routine.
|
||||
*
|
||||
* This module also supports per-thread 'application contexts'. With this
|
||||
* mode, a thread-based application will have a separate context, in which
|
||||
* it uses other ISC library services such as tasks or timers. Signals are
|
||||
* not caught in this mode, so that the application can handle the signals
|
||||
* in its preferred way.
|
||||
*
|
||||
* \li MP:
|
||||
* Clients must ensure that isc_app_start(), isc_app_run(), and
|
||||
* isc_app_finish() are called at most once. isc_app_shutdown()
|
||||
* is safe to use by any thread (provided isc_app_start() has been
|
||||
* called previously).
|
||||
*
|
||||
* The same note applies to isc_app_ctxXXX() functions, but in this case
|
||||
* it's a per-thread restriction. For example, a thread with an
|
||||
* application context must ensure that isc_app_ctxstart() with the
|
||||
* context is called at most once.
|
||||
*
|
||||
* \li Reliability:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Resources:
|
||||
* None.
|
||||
*
|
||||
* \li Security:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Standards:
|
||||
* None.
|
||||
*/
|
||||
|
||||
#include <isc/eventclass.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/magic.h>
|
||||
#include <isc/result.h>
|
||||
|
||||
/***
|
||||
*** Types
|
||||
***/
|
||||
|
||||
typedef isc_event_t isc_appevent_t;
|
||||
|
||||
#define ISC_APPEVENT_FIRSTEVENT (ISC_EVENTCLASS_APP + 0)
|
||||
#define ISC_APPEVENT_SHUTDOWN (ISC_EVENTCLASS_APP + 1)
|
||||
#define ISC_APPEVENT_LASTEVENT (ISC_EVENTCLASS_APP + 65535)
|
||||
|
||||
/*%
|
||||
* app module methods. Only app driver implementations use this structure.
|
||||
* Other clients should use the top-level interfaces (i.e., isc_app_xxx
|
||||
* functions). magic must be ISCAPI_APPMETHODS_MAGIC.
|
||||
*/
|
||||
typedef struct isc_appmethods {
|
||||
void (*ctxdestroy)(isc_appctx_t **ctxp);
|
||||
isc_result_t (*ctxstart)(isc_appctx_t *ctx);
|
||||
isc_result_t (*ctxrun)(isc_appctx_t *ctx);
|
||||
isc_result_t (*ctxsuspend)(isc_appctx_t *ctx);
|
||||
isc_result_t (*ctxshutdown)(isc_appctx_t *ctx);
|
||||
void (*ctxfinish)(isc_appctx_t *ctx);
|
||||
void (*settaskmgr)(isc_appctx_t *ctx,
|
||||
isc_taskmgr_t *timermgr);
|
||||
void (*setsocketmgr)(isc_appctx_t *ctx,
|
||||
isc_socketmgr_t *timermgr);
|
||||
void (*settimermgr)(isc_appctx_t *ctx,
|
||||
isc_timermgr_t *timermgr);
|
||||
} isc_appmethods_t;
|
||||
|
||||
/*%
|
||||
* This structure is actually just the common prefix of an application context
|
||||
* implementation's version of an isc_appctx_t.
|
||||
* \brief
|
||||
* Direct use of this structure by clients is forbidden. app implementations
|
||||
* may change the structure. 'magic' must be ISCAPI_APPCTX_MAGIC for any
|
||||
* of the isc_app_ routines to work. app implementations must maintain
|
||||
* all app context invariants.
|
||||
*/
|
||||
struct isc_appctx {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_appmethods_t *methods;
|
||||
};
|
||||
|
||||
#define ISCAPI_APPCTX_MAGIC ISC_MAGIC('A','a','p','c')
|
||||
#define ISCAPI_APPCTX_VALID(c) ((c) != NULL && \
|
||||
(c)->magic == ISCAPI_APPCTX_MAGIC)
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
isc_app_ctxstart(isc_appctx_t *ctx);
|
||||
|
||||
isc_result_t
|
||||
isc_app_start(void);
|
||||
/*!<
|
||||
* \brief Start an ISC library application.
|
||||
*
|
||||
* Notes:
|
||||
* This call should be made before any other ISC library call, and as
|
||||
* close to the beginning of the application as possible.
|
||||
*
|
||||
* Requires:
|
||||
* 'ctx' is a valid application context (for app_ctxstart()).
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_app_onrun(isc_mem_t *mctx, isc_task_t *task, isc_taskaction_t action,
|
||||
void *arg);
|
||||
/*!<
|
||||
* \brief Request delivery of an event when the application is run.
|
||||
*
|
||||
* Requires:
|
||||
*\li isc_app_start() has been called.
|
||||
*
|
||||
* Returns:
|
||||
* ISC_R_SUCCESS
|
||||
* ISC_R_NOMEMORY
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_app_ctxrun(isc_appctx_t *ctx);
|
||||
|
||||
isc_result_t
|
||||
isc_app_run(void);
|
||||
/*!<
|
||||
* \brief Run an ISC library application.
|
||||
*
|
||||
* Notes:
|
||||
*\li The caller (typically the initial thread of an application) will
|
||||
* block until shutdown is requested. When the call returns, the
|
||||
* caller should start shutting down the application.
|
||||
*
|
||||
* Requires:
|
||||
*\li isc_app_[ctx]start() has been called.
|
||||
*
|
||||
* Ensures:
|
||||
*\li Any events requested via isc_app_onrun() will have been posted (in
|
||||
* FIFO order) before isc_app_run() blocks.
|
||||
*\li 'ctx' is a valid application context (for app_ctxrun()).
|
||||
*
|
||||
* Returns:
|
||||
*\li ISC_R_SUCCESS Shutdown has been requested.
|
||||
*\li ISC_R_RELOAD Reload has been requested.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_app_ctxshutdown(isc_appctx_t *ctx);
|
||||
|
||||
isc_result_t
|
||||
isc_app_shutdown(void);
|
||||
/*!<
|
||||
* \brief Request application shutdown.
|
||||
*
|
||||
* Notes:
|
||||
*\li It is safe to call isc_app_shutdown() multiple times. Shutdown will
|
||||
* only be triggered once.
|
||||
*
|
||||
* Requires:
|
||||
*\li isc_app_[ctx]run() has been called.
|
||||
*\li 'ctx' is a valid application context (for app_ctxshutdown()).
|
||||
*
|
||||
* Returns:
|
||||
*\li ISC_R_SUCCESS
|
||||
*\li ISC_R_UNEXPECTED
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_app_ctxsuspend(isc_appctx_t *ctx);
|
||||
/*!<
|
||||
* \brief This has the same behavior as isc_app_ctxsuspend().
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_app_reload(void);
|
||||
/*!<
|
||||
* \brief Request application reload.
|
||||
*
|
||||
* Requires:
|
||||
*\li isc_app_run() has been called.
|
||||
*
|
||||
* Returns:
|
||||
*\li ISC_R_SUCCESS
|
||||
*\li ISC_R_UNEXPECTED
|
||||
*/
|
||||
|
||||
void
|
||||
isc_app_ctxfinish(isc_appctx_t *ctx);
|
||||
|
||||
void
|
||||
isc_app_finish(void);
|
||||
/*!<
|
||||
* \brief Finish an ISC library application.
|
||||
*
|
||||
* Notes:
|
||||
*\li This call should be made at or near the end of main().
|
||||
*
|
||||
* Requires:
|
||||
*\li isc_app_start() has been called.
|
||||
*\li 'ctx' is a valid application context (for app_ctxfinish()).
|
||||
*
|
||||
* Ensures:
|
||||
*\li Any resources allocated by isc_app_start() have been released.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_app_block(void);
|
||||
/*!<
|
||||
* \brief Indicate that a blocking operation will be performed.
|
||||
*
|
||||
* Notes:
|
||||
*\li If a blocking operation is in process, a call to isc_app_shutdown()
|
||||
* or an external signal will abort the program, rather than allowing
|
||||
* clean shutdown. This is primarily useful for reading user input.
|
||||
*
|
||||
* Requires:
|
||||
* \li isc_app_start() has been called.
|
||||
* \li No other blocking operations are in progress.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_app_unblock(void);
|
||||
/*!<
|
||||
* \brief Indicate that a blocking operation is complete.
|
||||
*
|
||||
* Notes:
|
||||
* \li When a blocking operation has completed, return the program to a
|
||||
* state where a call to isc_app_shutdown() or an external signal will
|
||||
* shutdown normally.
|
||||
*
|
||||
* Requires:
|
||||
* \li isc_app_start() has been called.
|
||||
* \li isc_app_block() has been called by the same thread.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp);
|
||||
/*!<
|
||||
* \brief Create an application context.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'mctx' is a valid memory context.
|
||||
*\li 'ctxp' != NULL && *ctxp == NULL.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_appctx_destroy(isc_appctx_t **ctxp);
|
||||
/*!<
|
||||
* \brief Destroy an application context.
|
||||
*
|
||||
* Requires:
|
||||
*\li '*ctxp' is a valid application context.
|
||||
*
|
||||
* Ensures:
|
||||
*\li *ctxp == NULL.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_appctx_settaskmgr(isc_appctx_t *ctx, isc_taskmgr_t *taskmgr);
|
||||
/*!<
|
||||
* \brief Associate a task manager with an application context.
|
||||
*
|
||||
* This must be done before running tasks within the application context.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'ctx' is a valid application context.
|
||||
*\li 'taskmgr' is a valid task manager.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_appctx_setsocketmgr(isc_appctx_t *ctx, isc_socketmgr_t *socketmgr);
|
||||
/*!<
|
||||
* \brief Associate a socket manager with an application context.
|
||||
*
|
||||
* This must be done before handling socket events within the application
|
||||
* context.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'ctx' is a valid application context.
|
||||
*\li 'socketmgr' is a valid socket manager.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_appctx_settimermgr(isc_appctx_t *ctx, isc_timermgr_t *timermgr);
|
||||
/*!<
|
||||
* \brief Associate a socket timer with an application context.
|
||||
*
|
||||
* This must be done before handling timer events within the application
|
||||
* context.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'ctx' is a valid application context.
|
||||
*\li 'timermgr' is a valid timer manager.
|
||||
*/
|
||||
|
||||
#ifdef USE_APPIMPREGISTER
|
||||
/*%<
|
||||
* See isc_appctx_create() above.
|
||||
*/
|
||||
typedef isc_result_t
|
||||
(*isc_appctxcreatefunc_t)(isc_mem_t *mctx, isc_appctx_t **ctxp);
|
||||
|
||||
isc_result_t
|
||||
isc_app_register(isc_appctxcreatefunc_t createfunc);
|
||||
/*%<
|
||||
* Register a new application implementation and add it to the list of
|
||||
* supported implementations. This function must be called when a different
|
||||
* event library is used than the one contained in the ISC library.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc__app_register(void);
|
||||
/*%<
|
||||
* A short cut function that specifies the application module in the ISC
|
||||
* library for isc_app_register(). An application that uses the ISC library
|
||||
* usually do not have to care about this function: it would call
|
||||
* isc_lib_register(), which internally calls this function.
|
||||
*/
|
||||
#endif /* USE_APPIMPREGISTER */
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_APP_H */
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1997-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: assertions.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $
|
||||
*/
|
||||
/*! \file isc/assertions.h
|
||||
*/
|
||||
|
||||
#ifndef ISC_ASSERTIONS_H
|
||||
#define ISC_ASSERTIONS_H 1
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*% isc assertion type */
|
||||
typedef enum {
|
||||
isc_assertiontype_require,
|
||||
isc_assertiontype_ensure,
|
||||
isc_assertiontype_insist,
|
||||
isc_assertiontype_invariant
|
||||
} isc_assertiontype_t;
|
||||
|
||||
typedef void (*isc_assertioncallback_t)(const char *, int, isc_assertiontype_t,
|
||||
const char *);
|
||||
|
||||
/* coverity[+kill] */
|
||||
ISC_PLATFORM_NORETURN_PRE
|
||||
void isc_assertion_failed(const char *, int, isc_assertiontype_t,
|
||||
const char *) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
void
|
||||
isc_assertion_setcallback(isc_assertioncallback_t);
|
||||
|
||||
const char *
|
||||
isc_assertion_typetotext(isc_assertiontype_t type);
|
||||
|
||||
#if defined(ISC_CHECK_ALL) || defined(__COVERITY__)
|
||||
#define ISC_CHECK_REQUIRE 1
|
||||
#define ISC_CHECK_ENSURE 1
|
||||
#define ISC_CHECK_INSIST 1
|
||||
#define ISC_CHECK_INVARIANT 1
|
||||
#endif
|
||||
|
||||
#if defined(ISC_CHECK_NONE) && !defined(__COVERITY__)
|
||||
#define ISC_CHECK_REQUIRE 0
|
||||
#define ISC_CHECK_ENSURE 0
|
||||
#define ISC_CHECK_INSIST 0
|
||||
#define ISC_CHECK_INVARIANT 0
|
||||
#endif
|
||||
|
||||
#ifndef ISC_CHECK_REQUIRE
|
||||
#define ISC_CHECK_REQUIRE 1
|
||||
#endif
|
||||
|
||||
#ifndef ISC_CHECK_ENSURE
|
||||
#define ISC_CHECK_ENSURE 1
|
||||
#endif
|
||||
|
||||
#ifndef ISC_CHECK_INSIST
|
||||
#define ISC_CHECK_INSIST 1
|
||||
#endif
|
||||
|
||||
#ifndef ISC_CHECK_INVARIANT
|
||||
#define ISC_CHECK_INVARIANT 1
|
||||
#endif
|
||||
|
||||
#if ISC_CHECK_REQUIRE != 0
|
||||
#define ISC_REQUIRE(cond) \
|
||||
((void) ((cond) || \
|
||||
((isc_assertion_failed)(__FILE__, __LINE__, \
|
||||
isc_assertiontype_require, \
|
||||
#cond), 0)))
|
||||
#else
|
||||
#define ISC_REQUIRE(cond) ((void) 0)
|
||||
#endif /* ISC_CHECK_REQUIRE */
|
||||
|
||||
#if ISC_CHECK_ENSURE != 0
|
||||
#define ISC_ENSURE(cond) \
|
||||
((void) ((cond) || \
|
||||
((isc_assertion_failed)(__FILE__, __LINE__, \
|
||||
isc_assertiontype_ensure, \
|
||||
#cond), 0)))
|
||||
#else
|
||||
#define ISC_ENSURE(cond) ((void) 0)
|
||||
#endif /* ISC_CHECK_ENSURE */
|
||||
|
||||
#if ISC_CHECK_INSIST != 0
|
||||
#define ISC_INSIST(cond) \
|
||||
((void) ((cond) || \
|
||||
((isc_assertion_failed)(__FILE__, __LINE__, \
|
||||
isc_assertiontype_insist, \
|
||||
#cond), 0)))
|
||||
#else
|
||||
#define ISC_INSIST(cond) ((void) 0)
|
||||
#endif /* ISC_CHECK_INSIST */
|
||||
|
||||
#if ISC_CHECK_INVARIANT != 0
|
||||
#define ISC_INVARIANT(cond) \
|
||||
((void) ((cond) || \
|
||||
((isc_assertion_failed)(__FILE__, __LINE__, \
|
||||
isc_assertiontype_invariant, \
|
||||
#cond), 0)))
|
||||
#else
|
||||
#define ISC_INVARIANT(cond) ((void) 0)
|
||||
#endif /* ISC_CHECK_INVARIANT */
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_ASSERTIONS_H */
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: backtrace.h,v 1.1.2.2 2015-04-09 05:47:07 lyang3 Exp $ */
|
||||
|
||||
/*! \file isc/backtrace.h
|
||||
* \brief provide a back trace of the running process to help debug problems.
|
||||
*
|
||||
* This module tries to get a back trace of the process using some platform
|
||||
* dependent way when available. It also manages an internal symbol table
|
||||
* that maps function addresses used in the process to their textual symbols.
|
||||
* This module is expected to be used to help debug when some fatal error
|
||||
* happens.
|
||||
*
|
||||
* IMPORTANT NOTE: since the (major) intended use case of this module is
|
||||
* dumping a back trace on a fatal error, normally followed by self termination,
|
||||
* functions defined in this module generally doesn't employ assertion checks
|
||||
* (if it did, a program bug could cause infinite recursive calls to a
|
||||
* backtrace function). These functions still perform minimal checks and return
|
||||
* ISC_R_FAILURE if they detect an error, but the caller should therefore be
|
||||
* very careful about the use of these functions, and generally discouraged to
|
||||
* use them except in an exit path. The exception is
|
||||
* isc_backtrace_getsymbolfromindex(), which is expected to be used in a
|
||||
* non-error-handling context and validates arguments with assertion checks.
|
||||
*/
|
||||
|
||||
#ifndef ISC_BACKTRACE_H
|
||||
#define ISC_BACKTRACE_H 1
|
||||
|
||||
/***
|
||||
*** Imports
|
||||
***/
|
||||
|
||||
#include <isc/types.h>
|
||||
|
||||
/***
|
||||
*** Types
|
||||
***/
|
||||
struct isc_backtrace_symmap {
|
||||
void *addr;
|
||||
const char *symbol;
|
||||
};
|
||||
|
||||
extern const int isc__backtrace_nsymbols;
|
||||
extern const isc_backtrace_symmap_t isc__backtrace_symtable[];
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
isc_result_t
|
||||
isc_backtrace_gettrace(void **addrs, int maxaddrs, int *nframes);
|
||||
/*%<
|
||||
* Get a back trace of the running process above this function itself. On
|
||||
* success, addrs[i] will store the address of the call point of the i-th
|
||||
* stack frame (addrs[0] is the caller of this function). *nframes will store
|
||||
* the total number of frames.
|
||||
*
|
||||
* Requires (note that these are not ensured by assertion checks, see above):
|
||||
*
|
||||
*\li 'addrs' is a valid array containing at least 'maxaddrs' void * entries.
|
||||
*
|
||||
*\li 'nframes' must be non NULL.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_FAILURE
|
||||
*\li #ISC_R_NOTFOUND
|
||||
*\li #ISC_R_NOTIMPLEMENTED
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_backtrace_getsymbolfromindex(int idx, const void **addrp,
|
||||
const char **symbolp);
|
||||
/*%<
|
||||
* Returns the content of the internal symbol table of the given index.
|
||||
* On success, *addrsp and *symbolp point to the address and the symbol of
|
||||
* the 'index'th entry of the table, respectively. If 'index' is not in the
|
||||
* range of the symbol table, ISC_R_RANGE will be returned.
|
||||
*
|
||||
* Requires
|
||||
*
|
||||
*\li 'addrp' must be non NULL && '*addrp' == NULL.
|
||||
*
|
||||
*\li 'symbolp' must be non NULL && '*symbolp' == NULL.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_RANGE
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_backtrace_getsymbol(const void *addr, const char **symbolp,
|
||||
unsigned long *offsetp);
|
||||
/*%<
|
||||
* Searches the internal symbol table for the symbol that most matches the
|
||||
* given 'addr'. On success, '*symbolp' will point to the name of function
|
||||
* to which the address 'addr' belong, and '*offsetp' will store the offset
|
||||
* from the function's entry address to 'addr'.
|
||||
*
|
||||
* Requires (note that these are not ensured by assertion checks, see above):
|
||||
*
|
||||
*\li 'symbolp' must be non NULL && '*symbolp' == NULL.
|
||||
*
|
||||
*\li 'offsetp' must be non NULL.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_FAILURE
|
||||
*\li #ISC_R_NOTFOUND
|
||||
*/
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_BACKTRACE_H */
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: base32.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_BASE32_H
|
||||
#define ISC_BASE32_H 1
|
||||
|
||||
/*! \file */
|
||||
|
||||
/*
|
||||
* Routines for manipulating base 32 and base 32 hex encoded data.
|
||||
* Based on RFC 4648.
|
||||
*
|
||||
* Base 32 hex preserves the sort order of data when it is encoded /
|
||||
* decoded.
|
||||
*/
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
isc_result_t
|
||||
isc_base32_totext(isc_region_t *source, int wordlength,
|
||||
const char *wordbreak, isc_buffer_t *target);
|
||||
isc_result_t
|
||||
isc_base32hex_totext(isc_region_t *source, int wordlength,
|
||||
const char *wordbreak, isc_buffer_t *target);
|
||||
/*!<
|
||||
* \brief Convert data into base32 encoded text.
|
||||
*
|
||||
* Notes:
|
||||
*\li The base32 encoded text in 'target' will be divided into
|
||||
* words of at most 'wordlength' characters, separated by
|
||||
* the 'wordbreak' string. No parentheses will surround
|
||||
* the text.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'source' is a region containing binary data
|
||||
*\li 'target' is a text buffer containing available space
|
||||
*\li 'wordbreak' points to a null-terminated string of
|
||||
* zero or more whitespace characters
|
||||
*
|
||||
* Ensures:
|
||||
*\li target will contain the base32 encoded version of the data
|
||||
* in source. The 'used' pointer in target will be advanced as
|
||||
* necessary.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_base32_decodestring(const char *cstr, isc_buffer_t *target);
|
||||
isc_result_t
|
||||
isc_base32hex_decodestring(const char *cstr, isc_buffer_t *target);
|
||||
/*!<
|
||||
* \brief Decode a null-terminated base32 string.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'cstr' is non-null.
|
||||
*\li 'target' is a valid buffer.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS -- the entire decoded representation of 'cstring'
|
||||
* fit in 'target'.
|
||||
*\li #ISC_R_BADBASE32 -- 'cstr' is not a valid base32 encoding.
|
||||
*
|
||||
* Other error returns are any possible error code from:
|
||||
*\li isc_lex_create(),
|
||||
*\li isc_lex_openbuffer(),
|
||||
*\li isc_base32_tobuffer().
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_base32_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length);
|
||||
isc_result_t
|
||||
isc_base32hex_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length);
|
||||
/*!<
|
||||
* \brief Convert base32 encoded text from a lexer context into data.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer context
|
||||
*\li 'target' is a buffer containing binary data
|
||||
*\li 'length' is an integer
|
||||
*
|
||||
* Ensures:
|
||||
*\li target will contain the data represented by the base32 encoded
|
||||
* string parsed by the lexer. No more than length bytes will be read,
|
||||
* if length is positive. The 'used' pointer in target will be
|
||||
* advanced as necessary.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_base32_decoderegion(isc_region_t *source, isc_buffer_t *target);
|
||||
isc_result_t
|
||||
isc_base32hex_decoderegion(isc_region_t *source, isc_buffer_t *target);
|
||||
/*!<
|
||||
* \brief Decode a packed (no white space permitted) base32 region.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'source' is a valid region.
|
||||
*\li 'target' is a valid buffer.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS -- the entire decoded representation of 'cstring'
|
||||
* fit in 'target'.
|
||||
*\li #ISC_R_BADBASE32 -- 'source' is not a valid base32 encoding.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_BASE32_H */
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: base64.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_BASE64_H
|
||||
#define ISC_BASE64_H 1
|
||||
|
||||
/*! \file isc/base64.h */
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
isc_result_t
|
||||
isc_base64_totext(isc_region_t *source, int wordlength,
|
||||
const char *wordbreak, isc_buffer_t *target);
|
||||
/*!<
|
||||
* \brief Convert data into base64 encoded text.
|
||||
*
|
||||
* Notes:
|
||||
*\li The base64 encoded text in 'target' will be divided into
|
||||
* words of at most 'wordlength' characters, separated by
|
||||
* the 'wordbreak' string. No parentheses will surround
|
||||
* the text.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'source' is a region containing binary data
|
||||
*\li 'target' is a text buffer containing available space
|
||||
*\li 'wordbreak' points to a null-terminated string of
|
||||
* zero or more whitespace characters
|
||||
*
|
||||
* Ensures:
|
||||
*\li target will contain the base64 encoded version of the data
|
||||
* in source. The 'used' pointer in target will be advanced as
|
||||
* necessary.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_base64_decodestring(const char *cstr, isc_buffer_t *target);
|
||||
/*!<
|
||||
* \brief Decode a null-terminated base64 string.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'cstr' is non-null.
|
||||
*\li 'target' is a valid buffer.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS -- the entire decoded representation of 'cstring'
|
||||
* fit in 'target'.
|
||||
*\li #ISC_R_BADBASE64 -- 'cstr' is not a valid base64 encoding.
|
||||
*
|
||||
* Other error returns are any possible error code from:
|
||||
*\li isc_lex_create(),
|
||||
*\li isc_lex_openbuffer(),
|
||||
*\li isc_base64_tobuffer().
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_base64_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length);
|
||||
/*!<
|
||||
* \brief Convert base64 encoded text from a lexer context into data.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer context
|
||||
*\li 'target' is a buffer containing binary data
|
||||
*\li 'length' is an integer
|
||||
*
|
||||
* Ensures:
|
||||
*\li target will contain the data represented by the base64 encoded
|
||||
* string parsed by the lexer. No more than length bytes will be read,
|
||||
* if length is positive. The 'used' pointer in target will be
|
||||
* advanced as necessary.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_BASE64_H */
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: bind9.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_BIND9_H
|
||||
#define ISC_BIND9_H 1
|
||||
|
||||
/*
|
||||
* This determines whether we are building BIND9 or using the exported
|
||||
* libisc/libdns libraries. The version of this file included in the
|
||||
* standard BIND9 build defines BIND9; the version included with the
|
||||
* exportable libraries does not.
|
||||
*/
|
||||
#define BIND9 1
|
||||
|
||||
#endif /* ISC_BIND9_H */
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: bitstring.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_BITSTRING_H
|
||||
#define ISC_BITSTRING_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/bitstring.h
|
||||
*
|
||||
* \brief Bitstring manipulation functions.
|
||||
*
|
||||
* A bitstring is a packed array of bits, stored in a contiguous
|
||||
* sequence of octets. The "most significant bit" (msb) of a bitstring
|
||||
* is the high bit of the first octet. The "least significant bit" of a
|
||||
* bitstring is the low bit of the last octet.
|
||||
*
|
||||
* Two bit numbering schemes are supported, "msb0" and "lsb0".
|
||||
*
|
||||
* In the "msb0" scheme, bit number 0 designates the most significant bit,
|
||||
* and any padding bits required to make the bitstring a multiple of 8 bits
|
||||
* long are added to the least significant end of the last octet.
|
||||
*
|
||||
* In the "lsb0" scheme, bit number 0 designates the least significant bit,
|
||||
* and any padding bits required to make the bitstring a multiple of 8 bits
|
||||
* long are added to the most significant end of the first octet.
|
||||
*
|
||||
* E.g., consider the bitstring "11010001111". This bitstring is 11 bits
|
||||
* long and will take two octets. Let "p" denote a pad bit. In the msb0
|
||||
* encoding, it would be
|
||||
*
|
||||
* \verbatim
|
||||
* Octet 0 Octet 1
|
||||
* |
|
||||
* 1 1 0 1 0 0 0 1 | 1 1 1 p p p p p
|
||||
* ^ | ^
|
||||
* | |
|
||||
* bit 0 bit 15
|
||||
* \endverbatim
|
||||
*
|
||||
* In the lsb0 encoding, it would be
|
||||
*
|
||||
* \verbatim
|
||||
* Octet 0 Octet 1
|
||||
* |
|
||||
* p p p p p 1 1 0 | 1 0 0 0 1 1 1 1
|
||||
* ^ | ^
|
||||
* | |
|
||||
* bit 15 bit 0
|
||||
* \endverbatim
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports
|
||||
***/
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/***
|
||||
*** Types
|
||||
***/
|
||||
|
||||
struct isc_bitstring {
|
||||
unsigned int magic;
|
||||
unsigned char * data;
|
||||
unsigned int length;
|
||||
unsigned int size;
|
||||
isc_boolean_t lsb0;
|
||||
};
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
void
|
||||
isc_bitstring_init(isc_bitstring_t *bitstring, unsigned char *data,
|
||||
unsigned int length, unsigned int size, isc_boolean_t lsb0);
|
||||
/*!<
|
||||
* \brief Make 'bitstring' refer to the bitstring of 'size' bits starting
|
||||
* at 'data'. 'length' bits of the bitstring are valid. If 'lsb0'
|
||||
* is set then, bit 0 refers to the least significant bit of the
|
||||
* bitstring. Otherwise bit 0 is the most significant bit.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'bitstring' points to a isc_bitstring_t.
|
||||
*
|
||||
*\li 'data' points to an array of unsigned char large enough to hold
|
||||
* 'size' bits.
|
||||
*
|
||||
*\li 'length' <= 'size'.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li 'bitstring' is a valid bitstring.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_bitstring_invalidate(isc_bitstring_t *bitstring);
|
||||
/*!<
|
||||
* \brief Invalidate 'bitstring'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'bitstring' is a valid bitstring.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li 'bitstring' is not a valid bitstring.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_bitstring_copy(isc_bitstring_t *source, unsigned int sbitpos,
|
||||
isc_bitstring_t *target, unsigned int tbitpos,
|
||||
unsigned int n);
|
||||
/*!<
|
||||
* \brief Starting at bit 'sbitpos', copy 'n' bits from 'source' to
|
||||
* the 'n' bits of 'target' starting at 'tbitpos'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'source' and target are valid bitstrings with the same lsb0 setting.
|
||||
*
|
||||
*\li 'sbitpos' + 'n' is less than or equal to the length of 'source'.
|
||||
*
|
||||
*\li 'tbitpos' + 'n' is less than or equal to the size of 'target'.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li The specified bits have been copied, and the length of 'target'
|
||||
* adjusted (if required).
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_BITSTRING_H */
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: boolean.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_BOOLEAN_H
|
||||
#define ISC_BOOLEAN_H 1
|
||||
|
||||
/*! \file isc/boolean.h */
|
||||
|
||||
typedef enum { isc_boolean_false = 0, isc_boolean_true = 1 } isc_boolean_t;
|
||||
|
||||
#define ISC_FALSE isc_boolean_false
|
||||
#define ISC_TRUE isc_boolean_true
|
||||
#define ISC_TF(x) ((x) ? ISC_TRUE : ISC_FALSE)
|
||||
|
||||
#endif /* ISC_BOOLEAN_H */
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: bufferlist.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_BUFFERLIST_H
|
||||
#define ISC_BUFFERLIST_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/bufferlist.h
|
||||
*
|
||||
*
|
||||
*\brief Buffer lists have no synchronization. Clients must ensure exclusive
|
||||
* access.
|
||||
*
|
||||
* \li Reliability:
|
||||
* No anticipated impact.
|
||||
|
||||
* \li Security:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Standards:
|
||||
* None.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports
|
||||
***/
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
unsigned int
|
||||
isc_bufferlist_usedcount(isc_bufferlist_t *bl);
|
||||
/*!<
|
||||
* \brief Return the length of the sum of all used regions of all buffers in
|
||||
* the buffer list 'bl'
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'bl' is not NULL.
|
||||
*
|
||||
* Returns:
|
||||
*\li sum of all used regions' lengths.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_bufferlist_availablecount(isc_bufferlist_t *bl);
|
||||
/*!<
|
||||
* \brief Return the length of the sum of all available regions of all buffers in
|
||||
* the buffer list 'bl'
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'bl' is not NULL.
|
||||
*
|
||||
* Returns:
|
||||
*\li sum of all available regions' lengths.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_BUFFERLIST_H */
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: commandline.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_COMMANDLINE_H
|
||||
#define ISC_COMMANDLINE_H 1
|
||||
|
||||
/*! \file isc/commandline.h */
|
||||
|
||||
#include <isc/boolean.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
|
||||
/*% Index into parent argv vector. */
|
||||
LIBISC_EXTERNAL_DATA extern int isc_commandline_index;
|
||||
/*% Character checked for validity. */
|
||||
LIBISC_EXTERNAL_DATA extern int isc_commandline_option;
|
||||
/*% Argument associated with option. */
|
||||
LIBISC_EXTERNAL_DATA extern char *isc_commandline_argument;
|
||||
/*% For printing error messages. */
|
||||
LIBISC_EXTERNAL_DATA extern char *isc_commandline_progname;
|
||||
/*% Print error message. */
|
||||
LIBISC_EXTERNAL_DATA extern isc_boolean_t isc_commandline_errprint;
|
||||
/*% Reset getopt. */
|
||||
LIBISC_EXTERNAL_DATA extern isc_boolean_t isc_commandline_reset;
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*% parse command line */
|
||||
int
|
||||
isc_commandline_parse(int argc, char * const *argv, const char *options);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_COMMANDLINE_H */
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: condition.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
/*
|
||||
* This provides a limited subset of the isc_condition_t
|
||||
* functionality for use by single-threaded programs that
|
||||
* need to block waiting for events. Only a single
|
||||
* call to isc_condition_wait() may be blocked at any given
|
||||
* time, and the _waituntil and _broadcast functions are not
|
||||
* supported. This is intended primarily for use by the omapi
|
||||
* library, and may go away once omapi goes away. Use for
|
||||
* other purposes is strongly discouraged.
|
||||
*/
|
||||
|
||||
#ifndef ISC_CONDITION_H
|
||||
#define ISC_CONDITION_H 1
|
||||
|
||||
#include <isc/mutex.h>
|
||||
|
||||
typedef int isc_condition_t;
|
||||
|
||||
isc_result_t isc__nothread_wait_hack(isc_condition_t *cp, isc_mutex_t *mp);
|
||||
isc_result_t isc__nothread_signal_hack(isc_condition_t *cp);
|
||||
|
||||
#define isc_condition_init(cp) \
|
||||
(*(cp) = 0, ISC_R_SUCCESS)
|
||||
|
||||
#define isc_condition_wait(cp, mp) \
|
||||
isc__nothread_wait_hack(cp, mp)
|
||||
|
||||
#define isc_condition_waituntil(cp, mp, tp) \
|
||||
((void)(cp), (void)(mp), (void)(tp), ISC_R_NOTIMPLEMENTED)
|
||||
|
||||
#define isc_condition_signal(cp) \
|
||||
isc__nothread_signal_hack(cp)
|
||||
|
||||
#define isc_condition_broadcast(cp) \
|
||||
((void)(cp), ISC_R_NOTIMPLEMENTED)
|
||||
|
||||
#define isc_condition_destroy(cp) \
|
||||
(*(cp) == 0 ? (*(cp) = -1, ISC_R_SUCCESS) : ISC_R_UNEXPECTED)
|
||||
|
||||
#endif /* ISC_CONDITION_H */
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: dir.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
/* Principal Authors: DCL */
|
||||
|
||||
#ifndef ISC_DIR_H
|
||||
#define ISC_DIR_H 1
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <sys/types.h> /* Required on some systems. */
|
||||
#include <dirent.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/result.h>
|
||||
|
||||
#define ISC_DIR_NAMEMAX 256
|
||||
#define ISC_DIR_PATHMAX 1024
|
||||
|
||||
/*% Directory Entry */
|
||||
typedef struct isc_direntry {
|
||||
/*!
|
||||
* Ideally, this should be NAME_MAX, but AIX does not define it by
|
||||
* default and dynamically allocating the space based on pathconf()
|
||||
* complicates things undesirably, as does adding special conditionals
|
||||
* just for AIX. So a comfortably sized buffer is chosen instead.
|
||||
*/
|
||||
char name[ISC_DIR_NAMEMAX];
|
||||
unsigned int length;
|
||||
} isc_direntry_t;
|
||||
|
||||
/*% Directory */
|
||||
typedef struct isc_dir {
|
||||
unsigned int magic;
|
||||
/*!
|
||||
* As with isc_direntry_t->name, making this "right" for all systems
|
||||
* is slightly problematic because AIX does not define PATH_MAX.
|
||||
*/
|
||||
char dirname[ISC_DIR_PATHMAX];
|
||||
isc_direntry_t entry;
|
||||
DIR * handle;
|
||||
} isc_dir_t;
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
void
|
||||
isc_dir_init(isc_dir_t *dir);
|
||||
|
||||
isc_result_t
|
||||
isc_dir_open(isc_dir_t *dir, const char *dirname);
|
||||
|
||||
isc_result_t
|
||||
isc_dir_read(isc_dir_t *dir);
|
||||
|
||||
isc_result_t
|
||||
isc_dir_reset(isc_dir_t *dir);
|
||||
|
||||
void
|
||||
isc_dir_close(isc_dir_t *dir);
|
||||
|
||||
isc_result_t
|
||||
isc_dir_chdir(const char *dirname);
|
||||
|
||||
isc_result_t
|
||||
isc_dir_chroot(const char *dirname);
|
||||
|
||||
isc_result_t
|
||||
isc_dir_createunique(char *templet);
|
||||
/*!<
|
||||
* Use a templet (such as from isc_file_mktemplate()) to create a uniquely
|
||||
* named, empty directory. The templet string is modified in place.
|
||||
* If result == ISC_R_SUCCESS, it is the name of the directory that was
|
||||
* created.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_DIR_H */
|
||||
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: entropy.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_ENTROPY_H
|
||||
#define ISC_ENTROPY_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/entropy.h
|
||||
* \brief The entropy API
|
||||
*
|
||||
* \li MP:
|
||||
* The entropy object is locked internally. All callbacks into
|
||||
* application-provided functions (for setup, gathering, and
|
||||
* shutdown of sources) are guaranteed to be called with the
|
||||
* entropy API lock held. This means these functions are
|
||||
* not permitted to call back into the entropy API.
|
||||
*
|
||||
* \li Reliability:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Resources:
|
||||
* A buffer, used as an entropy pool.
|
||||
*
|
||||
* \li Security:
|
||||
* While this code is believed to implement good entropy gathering
|
||||
* and distribution, it has not been reviewed by a cryptographic
|
||||
* expert.
|
||||
* Since the added entropy is only as good as the sources used,
|
||||
* this module could hand out bad data and never know it.
|
||||
*
|
||||
* \li Standards:
|
||||
* None.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports
|
||||
***/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/*@{*/
|
||||
/*% Entropy callback function. */
|
||||
typedef isc_result_t (*isc_entropystart_t)(isc_entropysource_t *source,
|
||||
void *arg, isc_boolean_t blocking);
|
||||
typedef isc_result_t (*isc_entropyget_t)(isc_entropysource_t *source,
|
||||
void *arg, isc_boolean_t blocking);
|
||||
typedef void (*isc_entropystop_t)(isc_entropysource_t *source, void *arg);
|
||||
/*@}*/
|
||||
|
||||
/***
|
||||
*** Flags.
|
||||
***/
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Extract only "good" data; return failure if there is not enough
|
||||
* data available and there are no sources which we can poll to get
|
||||
* data, or those sources are empty.
|
||||
*
|
||||
*
|
||||
*/
|
||||
#define ISC_ENTROPY_GOODONLY 0x00000001U
|
||||
/*!
|
||||
* \brief
|
||||
* Extract as much good data as possible, but if there isn't enough
|
||||
* at hand, return what is available. This flag only makes sense
|
||||
* when used with _GOODONLY.
|
||||
*/
|
||||
#define ISC_ENTROPY_PARTIAL 0x00000002U
|
||||
/*!
|
||||
* \brief
|
||||
* Block the task until data is available. This is contrary to the
|
||||
* ISC task system, where tasks should never block. However, if
|
||||
* this is a special purpose application where blocking a task is
|
||||
* acceptable (say, an offline zone signer) this flag may be set.
|
||||
* This flag only makes sense when used with _GOODONLY, and will
|
||||
* block regardless of the setting for _PARTIAL.
|
||||
*/
|
||||
#define ISC_ENTROPY_BLOCKING 0x00000004U
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* Estimate the amount of entropy contained in the sample pool.
|
||||
* If this is not set, the source will be gathered and periodically
|
||||
* mixed into the entropy pool, but no increment in contained entropy
|
||||
* will be assumed. This flag only makes sense on sample sources.
|
||||
*/
|
||||
#define ISC_ENTROPYSOURCE_ESTIMATE 0x00000001U
|
||||
|
||||
/*
|
||||
* For use with isc_entropy_usebestsource().
|
||||
*/
|
||||
/*!
|
||||
* \brief
|
||||
* Use the keyboard as the only entropy source.
|
||||
*/
|
||||
#define ISC_ENTROPY_KEYBOARDYES 1
|
||||
/*!
|
||||
* \brief
|
||||
* Never use the keyboard as an entropy source.
|
||||
*/
|
||||
#define ISC_ENTROPY_KEYBOARDNO 2
|
||||
/*!
|
||||
* \brief
|
||||
* Use the keyboard as an entropy source only if opening the
|
||||
* random device fails.
|
||||
*/
|
||||
#define ISC_ENTROPY_KEYBOARDMAYBE 3
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
isc_result_t
|
||||
isc_entropy_create(isc_mem_t *mctx, isc_entropy_t **entp);
|
||||
/*!<
|
||||
* \brief Create a new entropy object.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_entropy_attach(isc_entropy_t *ent, isc_entropy_t **entp);
|
||||
/*!<
|
||||
* Attaches to an entropy object.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_entropy_detach(isc_entropy_t **entp);
|
||||
/*!<
|
||||
* \brief Detaches from an entropy object.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_entropy_createfilesource(isc_entropy_t *ent, const char *fname);
|
||||
/*!<
|
||||
* \brief Create a new entropy source from a file.
|
||||
*
|
||||
* The file is assumed to contain good randomness, and will be mixed directly
|
||||
* into the pool with every byte adding 8 bits of entropy.
|
||||
*
|
||||
* The file will be put into non-blocking mode, so it may be a device file,
|
||||
* such as /dev/random. /dev/urandom should not be used here if it can
|
||||
* be avoided, since it will always provide data even if it isn't good.
|
||||
* We will make as much pseudorandom data as we need internally if our
|
||||
* caller asks for it.
|
||||
*
|
||||
* If we hit end-of-file, we will stop reading from this source. Callers
|
||||
* who require strong random data will get failure when our pool drains.
|
||||
* The file will never be opened/read again once EOF is reached.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_entropy_destroysource(isc_entropysource_t **sourcep);
|
||||
/*!<
|
||||
* \brief Removes an entropy source from the entropy system.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_entropy_createsamplesource(isc_entropy_t *ent,
|
||||
isc_entropysource_t **sourcep);
|
||||
/*!<
|
||||
* \brief Create an entropy source that consists of samples. Each sample is
|
||||
* added to the source via isc_entropy_addsamples(), below.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_entropy_createcallbacksource(isc_entropy_t *ent,
|
||||
isc_entropystart_t start,
|
||||
isc_entropyget_t get,
|
||||
isc_entropystop_t stop,
|
||||
void *arg,
|
||||
isc_entropysource_t **sourcep);
|
||||
/*!<
|
||||
* \brief Create an entropy source that is polled via a callback.
|
||||
*
|
||||
* This would
|
||||
* be used when keyboard input is used, or a GUI input method. It can
|
||||
* also be used to hook in any external entropy source.
|
||||
*
|
||||
* Samples are added via isc_entropy_addcallbacksample(), below.
|
||||
* _addcallbacksample() is the only function which may be called from
|
||||
* within an entropy API callback function.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_entropy_stopcallbacksources(isc_entropy_t *ent);
|
||||
/*!<
|
||||
* \brief Call the stop functions for callback sources that have had their
|
||||
* start functions called.
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
isc_result_t
|
||||
isc_entropy_addcallbacksample(isc_entropysource_t *source, isc_uint32_t sample,
|
||||
isc_uint32_t extra);
|
||||
isc_result_t
|
||||
isc_entropy_addsample(isc_entropysource_t *source, isc_uint32_t sample,
|
||||
isc_uint32_t extra);
|
||||
/*!<
|
||||
* \brief Add a sample to the sample source.
|
||||
*
|
||||
* The sample MUST be a timestamp
|
||||
* that increases over time, with the exception of wrap-around for
|
||||
* extremely high resolution timers which will quickly wrap-around
|
||||
* a 32-bit integer.
|
||||
*
|
||||
* The "extra" parameter is used only to add a bit more unpredictable
|
||||
* data. It is not used other than included in the hash of samples.
|
||||
*
|
||||
* When in an entropy API callback function, _addcallbacksource() must be
|
||||
* used. At all other times, _addsample() must be used.
|
||||
*/
|
||||
/*@}*/
|
||||
|
||||
isc_result_t
|
||||
isc_entropy_getdata(isc_entropy_t *ent, void *data, unsigned int length,
|
||||
unsigned int *returned, unsigned int flags);
|
||||
/*!<
|
||||
* \brief Extract data from the entropy pool. This may load the pool from various
|
||||
* sources.
|
||||
*
|
||||
* Do this by stiring the pool and returning a part of hash as randomness.
|
||||
* Note that no secrets are given away here since parts of the hash are
|
||||
* xored together before returned.
|
||||
*
|
||||
* Honor the request from the caller to only return good data, any data,
|
||||
* etc.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_entropy_putdata(isc_entropy_t *ent, void *data, unsigned int length,
|
||||
isc_uint32_t entropy);
|
||||
/*!<
|
||||
* \brief Add "length" bytes in "data" to the entropy pool, incrementing the
|
||||
* pool's entropy count by "entropy."
|
||||
*
|
||||
* These bytes will prime the pseudorandom portion even if no entropy is
|
||||
* actually added.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_entropy_stats(isc_entropy_t *ent, FILE *out);
|
||||
/*!<
|
||||
* \brief Dump some (trivial) stats to the stdio stream "out".
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_entropy_status(isc_entropy_t *end);
|
||||
/*
|
||||
* Returns the number of bits the pool currently contains. This is just
|
||||
* an estimate.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_entropy_usebestsource(isc_entropy_t *ectx, isc_entropysource_t **source,
|
||||
const char *randomfile, int use_keyboard);
|
||||
/*!<
|
||||
* \brief Use whatever source of entropy is best.
|
||||
*
|
||||
* Notes:
|
||||
*\li If "randomfile" is not NULL, open it with
|
||||
* isc_entropy_createfilesource().
|
||||
*
|
||||
*\li If "randomfile" is NULL and the system's random device was detected
|
||||
* when the program was configured and built, open that device with
|
||||
* isc_entropy_createfilesource().
|
||||
*
|
||||
*\li If "use_keyboard" is #ISC_ENTROPY_KEYBOARDYES, then always open
|
||||
* the keyboard as an entropy source (possibly in addition to
|
||||
* "randomfile" or the random device).
|
||||
*
|
||||
*\li If "use_keyboard" is #ISC_ENTROPY_KEYBOARDMAYBE, open the keyboard only
|
||||
* if opening the random file/device fails. A message will be
|
||||
* printed describing the need for keyboard input.
|
||||
*
|
||||
*\li If "use_keyboard" is #ISC_ENTROPY_KEYBOARDNO, the keyboard will
|
||||
* never be opened.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS if at least one source of entropy could be started.
|
||||
*
|
||||
*\li #ISC_R_NOENTROPY if use_keyboard is #ISC_ENTROPY_KEYBOARDNO and
|
||||
* there is no random device pathname compiled into the program.
|
||||
*
|
||||
*\li A return code from isc_entropy_createfilesource() or
|
||||
* isc_entropy_createcallbacksource().
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_ENTROPY_H */
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2007, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: errno2result.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef UNIX_ERRNO2RESULT_H
|
||||
#define UNIX_ERRNO2RESULT_H 1
|
||||
|
||||
/*! \file */
|
||||
|
||||
/* XXXDCL this should be moved to lib/isc/include/isc/errno2result.h. */
|
||||
|
||||
#include <errno.h> /* Provides errno. */
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
#define isc__errno2result(x) isc___errno2result(x, __FILE__, __LINE__)
|
||||
|
||||
isc_result_t
|
||||
isc___errno2result(int posixerrno, const char *file, unsigned int line);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* UNIX_ERRNO2RESULT_H */
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2002 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: event.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_EVENT_H
|
||||
#define ISC_EVENT_H 1
|
||||
|
||||
/*! \file isc/event.h */
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/*****
|
||||
***** Events.
|
||||
*****/
|
||||
|
||||
typedef void (*isc_eventdestructor_t)(isc_event_t *);
|
||||
|
||||
#define ISC_EVENT_COMMON(ltype) \
|
||||
size_t ev_size; \
|
||||
unsigned int ev_attributes; \
|
||||
void * ev_tag; \
|
||||
isc_eventtype_t ev_type; \
|
||||
isc_taskaction_t ev_action; \
|
||||
void * ev_arg; \
|
||||
void * ev_sender; \
|
||||
isc_eventdestructor_t ev_destroy; \
|
||||
void * ev_destroy_arg; \
|
||||
ISC_LINK(ltype) ev_link
|
||||
|
||||
/*%
|
||||
* Attributes matching a mask of 0x000000ff are reserved for the task library's
|
||||
* definition. Attributes of 0xffffff00 may be used by the application
|
||||
* or non-ISC libraries.
|
||||
*/
|
||||
#define ISC_EVENTATTR_NOPURGE 0x00000001
|
||||
|
||||
/*%
|
||||
* The ISC_EVENTATTR_CANCELED attribute is intended to indicate
|
||||
* that an event is delivered as a result of a canceled operation
|
||||
* rather than successful completion, by mutual agreement
|
||||
* between the sender and receiver. It is not set or used by
|
||||
* the task system.
|
||||
*/
|
||||
#define ISC_EVENTATTR_CANCELED 0x00000002
|
||||
|
||||
#define ISC_EVENT_INIT(event, sz, at, ta, ty, ac, ar, sn, df, da) \
|
||||
do { \
|
||||
(event)->ev_size = (sz); \
|
||||
(event)->ev_attributes = (at); \
|
||||
(event)->ev_tag = (ta); \
|
||||
(event)->ev_type = (ty); \
|
||||
(event)->ev_action = (ac); \
|
||||
(event)->ev_arg = (ar); \
|
||||
(event)->ev_sender = (sn); \
|
||||
(event)->ev_destroy = (df); \
|
||||
(event)->ev_destroy_arg = (da); \
|
||||
ISC_LINK_INIT((event), ev_link); \
|
||||
} while (0)
|
||||
|
||||
/*%
|
||||
* This structure is public because "subclassing" it may be useful when
|
||||
* defining new event types.
|
||||
*/
|
||||
struct isc_event {
|
||||
ISC_EVENT_COMMON(struct isc_event);
|
||||
};
|
||||
|
||||
#define ISC_EVENTTYPE_FIRSTEVENT 0x00000000
|
||||
#define ISC_EVENTTYPE_LASTEVENT 0xffffffff
|
||||
|
||||
#define ISC_EVENT_PTR(p) ((isc_event_t **)(void *)(p))
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_event_t *
|
||||
isc_event_allocate(isc_mem_t *mctx, void *sender, isc_eventtype_t type,
|
||||
isc_taskaction_t action, const void *arg, size_t size);
|
||||
/*%<
|
||||
* Allocate an event structure.
|
||||
*
|
||||
* Allocate and initialize in a structure with initial elements
|
||||
* defined by:
|
||||
*
|
||||
* \code
|
||||
* struct {
|
||||
* ISC_EVENT_COMMON(struct isc_event);
|
||||
* ...
|
||||
* };
|
||||
* \endcode
|
||||
*
|
||||
* Requires:
|
||||
*\li 'size' >= sizeof(struct isc_event)
|
||||
*\li 'action' to be non NULL
|
||||
*
|
||||
* Returns:
|
||||
*\li a pointer to a initialized structure of the requested size.
|
||||
*\li NULL if unable to allocate memory.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_event_free(isc_event_t **);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_EVENT_H */
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: eventclass.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_EVENTCLASS_H
|
||||
#define ISC_EVENTCLASS_H 1
|
||||
|
||||
/*! \file isc/eventclass.h
|
||||
***** Registry of Predefined Event Type Classes
|
||||
*****/
|
||||
|
||||
/*%
|
||||
* An event class is an unsigned 16 bit number. Each class may contain up
|
||||
* to 65536 events. An event type is formed by adding the event number
|
||||
* within the class to the class number.
|
||||
*
|
||||
*/
|
||||
|
||||
#define ISC_EVENTCLASS(eclass) ((eclass) << 16)
|
||||
|
||||
/*@{*/
|
||||
/*!
|
||||
* Classes < 1024 are reserved for ISC use.
|
||||
* Event classes >= 1024 and <= 65535 are reserved for application use.
|
||||
*/
|
||||
|
||||
#define ISC_EVENTCLASS_TASK ISC_EVENTCLASS(0)
|
||||
#define ISC_EVENTCLASS_TIMER ISC_EVENTCLASS(1)
|
||||
#define ISC_EVENTCLASS_SOCKET ISC_EVENTCLASS(2)
|
||||
#define ISC_EVENTCLASS_FILE ISC_EVENTCLASS(3)
|
||||
#define ISC_EVENTCLASS_DNS ISC_EVENTCLASS(4)
|
||||
#define ISC_EVENTCLASS_APP ISC_EVENTCLASS(5)
|
||||
#define ISC_EVENTCLASS_OMAPI ISC_EVENTCLASS(6)
|
||||
#define ISC_EVENTCLASS_RATELIMITER ISC_EVENTCLASS(7)
|
||||
#define ISC_EVENTCLASS_ISCCC ISC_EVENTCLASS(8)
|
||||
/*@}*/
|
||||
|
||||
#endif /* ISC_EVENTCLASS_H */
|
||||
@@ -0,0 +1,305 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: file.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_FILE_H
|
||||
#define ISC_FILE_H 1
|
||||
|
||||
/*! \file isc/file.h */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
isc_file_settime(const char *file, isc_time_t *itime);
|
||||
|
||||
isc_result_t
|
||||
isc_file_getmodtime(const char *file, isc_time_t *itime);
|
||||
/*!<
|
||||
* \brief Get the time of last modification of a file.
|
||||
*
|
||||
* Notes:
|
||||
*\li The time that is set is relative to the (OS-specific) epoch, as are
|
||||
* all isc_time_t structures.
|
||||
*
|
||||
* Requires:
|
||||
*\li file != NULL.
|
||||
*\li time != NULL.
|
||||
*
|
||||
* Ensures:
|
||||
*\li If the file could not be accessed, 'time' is unchanged.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
* Success.
|
||||
*\li #ISC_R_NOTFOUND
|
||||
* No such file exists.
|
||||
*\li #ISC_R_INVALIDFILE
|
||||
* The path specified was not usable by the operating system.
|
||||
*\li #ISC_R_NOPERM
|
||||
* The file's metainformation could not be retrieved because
|
||||
* permission was denied to some part of the file's path.
|
||||
*\li #ISC_R_EIO
|
||||
* Hardware error interacting with the filesystem.
|
||||
*\li #ISC_R_UNEXPECTED
|
||||
* Something totally unexpected happened.
|
||||
*
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_file_mktemplate(const char *path, char *buf, size_t buflen);
|
||||
/*!<
|
||||
* \brief Generate a template string suitable for use with isc_file_openunique().
|
||||
*
|
||||
* Notes:
|
||||
*\li This function is intended to make creating temporary files
|
||||
* portable between different operating systems.
|
||||
*
|
||||
*\li The path is prepended to an implementation-defined string and
|
||||
* placed into buf. The string has no path characters in it,
|
||||
* and its maximum length is 14 characters plus a NUL. Thus
|
||||
* buflen should be at least strlen(path) + 15 characters or
|
||||
* an error will be returned.
|
||||
*
|
||||
* Requires:
|
||||
*\li buf != NULL.
|
||||
*
|
||||
* Ensures:
|
||||
*\li If result == #ISC_R_SUCCESS:
|
||||
* buf contains a string suitable for use as the template argument
|
||||
* to isc_file_openunique().
|
||||
*
|
||||
*\li If result != #ISC_R_SUCCESS:
|
||||
* buf is unchanged.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS Success.
|
||||
*\li #ISC_R_NOSPACE buflen indicates buf is too small for the catenation
|
||||
* of the path with the internal template string.
|
||||
*/
|
||||
|
||||
|
||||
isc_result_t
|
||||
isc_file_openunique(char *templet, FILE **fp);
|
||||
isc_result_t
|
||||
isc_file_openuniqueprivate(char *templet, FILE **fp);
|
||||
isc_result_t
|
||||
isc_file_openuniquemode(char *templet, int mode, FILE **fp);
|
||||
/*!<
|
||||
* \brief Create and open a file with a unique name based on 'templet'.
|
||||
*
|
||||
* Notes:
|
||||
*\li 'template' is a reserved work in C++. If you want to complain
|
||||
* about the spelling of 'templet', first look it up in the
|
||||
* Merriam-Webster English dictionary. (http://www.m-w.com/)
|
||||
*
|
||||
*\li This function works by using the template to generate file names.
|
||||
* The template must be a writable string, as it is modified in place.
|
||||
* Trailing X characters in the file name (full file name on Unix,
|
||||
* basename on Win32 -- eg, tmp-XXXXXX vs XXXXXX.tmp, respectively)
|
||||
* are replaced with ASCII characters until a non-existent filename
|
||||
* is found. If the template does not include pathname information,
|
||||
* the files in the working directory of the program are searched.
|
||||
*
|
||||
*\li isc_file_mktemplate is a good, portable way to get a template.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'fp' is non-NULL and '*fp' is NULL.
|
||||
*
|
||||
*\li 'template' is non-NULL, and of a form suitable for use by
|
||||
* the system as described above.
|
||||
*
|
||||
* Ensures:
|
||||
*\li If result is #ISC_R_SUCCESS:
|
||||
* *fp points to an stream opening in stdio's "w+" mode.
|
||||
*
|
||||
*\li If result is not #ISC_R_SUCCESS:
|
||||
* *fp is NULL.
|
||||
*
|
||||
* No file is open. Even if one was created (but unable
|
||||
* to be reopened as a stdio FILE pointer) then it has been
|
||||
* removed.
|
||||
*
|
||||
*\li This function does *not* ensure that the template string has not been
|
||||
* modified, even if the operation was unsuccessful.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
* Success.
|
||||
*\li #ISC_R_EXISTS
|
||||
* No file with a unique name could be created based on the
|
||||
* template.
|
||||
*\li #ISC_R_INVALIDFILE
|
||||
* The path specified was not usable by the operating system.
|
||||
*\li #ISC_R_NOPERM
|
||||
* The file could not be created because permission was denied
|
||||
* to some part of the file's path.
|
||||
*\li #ISC_R_IOERROR
|
||||
* Hardware error interacting with the filesystem.
|
||||
*\li #ISC_R_UNEXPECTED
|
||||
* Something totally unexpected happened.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_file_remove(const char *filename);
|
||||
/*!<
|
||||
* \brief Remove the file named by 'filename'.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_file_rename(const char *oldname, const char *newname);
|
||||
/*!<
|
||||
* \brief Rename the file 'oldname' to 'newname'.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_file_exists(const char *pathname);
|
||||
/*!<
|
||||
* \brief Return #ISC_TRUE if the calling process can tell that the given file exists.
|
||||
* Will not return true if the calling process has insufficient privileges
|
||||
* to search the entire path.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_file_isabsolute(const char *filename);
|
||||
/*!<
|
||||
* \brief Return #ISC_TRUE if the given file name is absolute.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_file_isplainfile(const char *name);
|
||||
/*!<
|
||||
* \brief Check that the file is a plain file
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
* Success. The file is a plain file.
|
||||
*\li #ISC_R_INVALIDFILE
|
||||
* The path specified was not usable by the operating system.
|
||||
*\li #ISC_R_FILENOTFOUND
|
||||
* The file does not exist. This return code comes from
|
||||
* errno=ENOENT when stat returns -1. This code is mentioned
|
||||
* here, because in logconf.c, it is the one rcode that is
|
||||
* permitted in addition to ISC_R_SUCCESS. This is done since
|
||||
* the next call in logconf.c is to isc_stdio_open(), which
|
||||
* will create the file if it can.
|
||||
*\li #other ISC_R_* errors translated from errno
|
||||
* These occur when stat returns -1 and an errno.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_file_iscurrentdir(const char *filename);
|
||||
/*!<
|
||||
* \brief Return #ISC_TRUE if the given file name is the current directory (".").
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_file_ischdiridempotent(const char *filename);
|
||||
/*%<
|
||||
* Return #ISC_TRUE if calling chdir(filename) multiple times will give
|
||||
* the same result as calling it once.
|
||||
*/
|
||||
|
||||
const char *
|
||||
isc_file_basename(const char *filename);
|
||||
/*%<
|
||||
* Return the final component of the path in the file name.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_file_progname(const char *filename, char *buf, size_t buflen);
|
||||
/*!<
|
||||
* \brief Given an operating system specific file name "filename"
|
||||
* referring to a program, return the canonical program name.
|
||||
*
|
||||
*
|
||||
* Any directory prefix or executable file name extension (if
|
||||
* used on the OS in case) is stripped. On systems where program
|
||||
* names are case insensitive, the name is canonicalized to all
|
||||
* lower case. The name is written to 'buf', an array of 'buflen'
|
||||
* chars, and null terminated.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_NOSPACE The name did not fit in 'buf'.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_file_template(const char *path, const char *templet, char *buf,
|
||||
size_t buflen);
|
||||
/*%<
|
||||
* Create an OS specific template using 'path' to define the directory
|
||||
* 'templet' to describe the filename and store the result in 'buf'
|
||||
* such that path can be renamed to buf atomically.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_file_renameunique(const char *file, char *templet);
|
||||
/*%<
|
||||
* Rename 'file' using 'templet' as a template for the new file name.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_file_absolutepath(const char *filename, char *path, size_t pathlen);
|
||||
/*%<
|
||||
* Given a file name, return the fully qualified path to the file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* XXX We should also have a isc_file_writeeopen() function
|
||||
* for safely open a file in a publicly writable directory
|
||||
* (see write_open() in BIND 8's ns_config.c).
|
||||
*/
|
||||
#ifndef SYS_VXWORKS
|
||||
isc_result_t
|
||||
isc_file_truncate(const char *filename, isc_offset_t size);
|
||||
/*%<
|
||||
* Truncate/extend the file specified to 'size' bytes.
|
||||
*/
|
||||
#endif
|
||||
|
||||
isc_result_t
|
||||
isc_file_safecreate(const char *filename, FILE **fp);
|
||||
/*%<
|
||||
* Open 'filename' for writing, truncating if necessary. Ensure that
|
||||
* if it existed it was a normal file. If creating the file, ensure
|
||||
* that only the owner can read/write it.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_file_splitpath(isc_mem_t *mctx, char *path,
|
||||
char **dirname, char **basename);
|
||||
/*%<
|
||||
* Split a path into dirname and basename. If 'path' contains no slash
|
||||
* (or, on windows, backslash), then '*dirname' is set to ".".
|
||||
*
|
||||
* Allocates memory for '*dirname', which can be freed with isc_mem_free().
|
||||
*
|
||||
* Returns:
|
||||
* - ISC_R_SUCCESS on success
|
||||
* - ISC_R_INVALIDFILE if 'path' is empty or ends with '/'
|
||||
* - ISC_R_NOMEMORY if unable to allocate memory
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_FILE_H */
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: formatcheck.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_FORMATCHECK_H
|
||||
#define ISC_FORMATCHECK_H 1
|
||||
|
||||
/*! \file isc/formatcheck.h */
|
||||
|
||||
/*%
|
||||
* ISC_FORMAT_PRINTF().
|
||||
*
|
||||
* \li fmt is the location of the format string parameter.
|
||||
* \li args is the location of the first argument (or 0 for no argument checking).
|
||||
*
|
||||
* Note:
|
||||
* \li The first parameter is 1, not 0.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#define ISC_FORMAT_PRINTF(fmt, args) __attribute__((__format__(__printf__, fmt, args)))
|
||||
#else
|
||||
#define ISC_FORMAT_PRINTF(fmt, args)
|
||||
#endif
|
||||
|
||||
#endif /* ISC_FORMATCHECK_H */
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: fsaccess.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_FSACCESS_H
|
||||
#define ISC_FSACCESS_H 1
|
||||
|
||||
/*! \file isc/fsaccess.h
|
||||
* \brief The ISC filesystem access module encapsulates the setting of file
|
||||
* and directory access permissions into one API that is meant to be
|
||||
* portable to multiple operating systems.
|
||||
*
|
||||
* The two primary operating system flavors that are initially accommodated
|
||||
* are POSIX and Windows NT 4.0 and later. The Windows NT access model is
|
||||
* considerable more flexible than POSIX's model (as much as I am loathe to
|
||||
* admit it), and so the ISC API has a higher degree of complexity than would
|
||||
* be needed to simply address POSIX's needs.
|
||||
*
|
||||
* The full breadth of NT's flexibility is not available either, for the
|
||||
* present time. Much of it is to provide compatibility with what Unix
|
||||
* programmers are expecting. This is also due to not yet really needing all
|
||||
* of the functionality of an NT system (or, for that matter, a POSIX system)
|
||||
* in BIND9, and so resolving how to handle the various incompatibilities has
|
||||
* been a purely theoretical exercise with no operational experience to
|
||||
* indicate how flawed the thinking may be.
|
||||
*
|
||||
* Some of the more notable dumbing down of NT for this API includes:
|
||||
*
|
||||
*\li Each of FILE_READ_DATA and FILE_READ_EA are set with #ISC_FSACCESS_READ.
|
||||
*
|
||||
* \li All of FILE_WRITE_DATA, FILE_WRITE_EA and FILE_APPEND_DATA are
|
||||
* set with #ISC_FSACCESS_WRITE. FILE_WRITE_ATTRIBUTES is not set
|
||||
* so as to be consistent with Unix, where only the owner of the file
|
||||
* or the superuser can change the attributes/mode of a file.
|
||||
*
|
||||
* \li Both of FILE_ADD_FILE and FILE_ADD_SUBDIRECTORY are set with
|
||||
* #ISC_FSACCESS_CREATECHILD. This is similar to setting the WRITE
|
||||
* permission on a Unix directory.
|
||||
*
|
||||
* \li SYNCHRONIZE is always set for files and directories, unless someone
|
||||
* can give me a reason why this is a bad idea.
|
||||
*
|
||||
* \li READ_CONTROL and FILE_READ_ATTRIBUTES are always set; this is
|
||||
* consistent with Unix, where any file or directory can be stat()'d
|
||||
* unless the directory path disallows complete access somewhere along
|
||||
* the way.
|
||||
*
|
||||
* \li WRITE_DAC is only set for the owner. This too is consistent with
|
||||
* Unix, and is tighter security than allowing anyone else to be
|
||||
* able to set permissions.
|
||||
*
|
||||
* \li DELETE is only set for the owner. On Unix the ability to delete
|
||||
* a file is controlled by the directory permissions, but it isn't
|
||||
* currently clear to me what happens on NT if the directory has
|
||||
* FILE_DELETE_CHILD set but a file within it does not have DELETE
|
||||
* set. Always setting DELETE on the file/directory for the owner
|
||||
* gives maximum flexibility to the owner without exposing the
|
||||
* file to deletion by others.
|
||||
*
|
||||
* \li WRITE_OWNER is never set. This too is consistent with Unix,
|
||||
* and is also tighter security than allowing anyone to change the
|
||||
* ownership of the file apart from the superu..ahem, Administrator.
|
||||
*
|
||||
* \li Inheritance is set to NO_INHERITANCE.
|
||||
*
|
||||
* Unix's dumbing down includes:
|
||||
*
|
||||
* \li The sticky bit cannot be set.
|
||||
*
|
||||
* \li setuid and setgid cannot be set.
|
||||
*
|
||||
* \li Only regular files and directories can be set.
|
||||
*
|
||||
* The rest of this comment discusses a few of the incompatibilities
|
||||
* between the two systems that need more thought if this API is to
|
||||
* be extended to accommodate them.
|
||||
*
|
||||
* The Windows standard access right "DELETE" doesn't have a direct
|
||||
* equivalent in the Unix world, so it isn't clear what should be done
|
||||
* with it.
|
||||
*
|
||||
* The Unix sticky bit is not supported. While NT does have a concept
|
||||
* of allowing users to create files in a directory but not delete or
|
||||
* rename them, it does not have a concept of allowing them to be deleted
|
||||
* if they are owned by the user trying to delete/rename. While it is
|
||||
* probable that something could be cobbled together in NT 5 with inheritance,
|
||||
* it can't really be done in NT 4 as a single property that you could
|
||||
* set on a directory. You'd need to coordinate something with file creation
|
||||
* so that every file created had DELETE set for the owner but noone else.
|
||||
*
|
||||
* On Unix systems, setting #ISC_FSACCESS_LISTDIRECTORY sets READ.
|
||||
* ... setting either #ISC_FSACCESS_CREATECHILD or #ISC_FSACCESS_DELETECHILD
|
||||
* sets WRITE.
|
||||
* ... setting #ISC_FSACCESS_ACCESSCHILD sets EXECUTE.
|
||||
*
|
||||
* On NT systems, setting #ISC_FSACCESS_LISTDIRECTORY sets FILE_LIST_DIRECTORY.
|
||||
* ... setting #ISC_FSACCESS_CREATECHILD sets FILE_CREATE_CHILD independently.
|
||||
* ... setting #ISC_FSACCESS_DELETECHILD sets FILE_DELETE_CHILD independently.
|
||||
* ... setting #ISC_FSACCESS_ACCESSCHILD sets FILE_TRAVERSE.
|
||||
*
|
||||
* Unresolved: XXXDCL
|
||||
* \li What NT access right controls the ability to rename a file?
|
||||
* \li How does DELETE work? If a directory has FILE_DELETE_CHILD but a
|
||||
* file or directory within it does not have DELETE, is that file
|
||||
* or directory deletable?
|
||||
* \li To implement isc_fsaccess_get(), mapping an existing Unix permission
|
||||
* mode_t back to an isc_fsaccess_t is pretty trivial; however, mapping
|
||||
* an NT DACL could be impossible to do in a responsible way.
|
||||
* \li Similarly, trying to implement the functionality of being able to
|
||||
* say "add group writability to whatever permissions already exist"
|
||||
* could be tricky on NT because of the order-of-entry issue combined
|
||||
* with possibly having one or more matching ACEs already explicitly
|
||||
* granting or denying access. Because this functionality is
|
||||
* not yet needed by the ISC, no code has been written to try to
|
||||
* solve this problem.
|
||||
*/
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/*
|
||||
* Trustees.
|
||||
*/
|
||||
#define ISC_FSACCESS_OWNER 0x1 /*%< User account. */
|
||||
#define ISC_FSACCESS_GROUP 0x2 /*%< Primary group owner. */
|
||||
#define ISC_FSACCESS_OTHER 0x4 /*%< Not the owner or the group owner. */
|
||||
#define ISC_FSACCESS_WORLD 0x7 /*%< User, Group, Other. */
|
||||
|
||||
/*
|
||||
* Types of permission.
|
||||
*/
|
||||
#define ISC_FSACCESS_READ 0x00000001 /*%< File only. */
|
||||
#define ISC_FSACCESS_WRITE 0x00000002 /*%< File only. */
|
||||
#define ISC_FSACCESS_EXECUTE 0x00000004 /*%< File only. */
|
||||
#define ISC_FSACCESS_CREATECHILD 0x00000008 /*%< Dir only. */
|
||||
#define ISC_FSACCESS_DELETECHILD 0x00000010 /*%< Dir only. */
|
||||
#define ISC_FSACCESS_LISTDIRECTORY 0x00000020 /*%< Dir only. */
|
||||
#define ISC_FSACCESS_ACCESSCHILD 0x00000040 /*%< Dir only. */
|
||||
|
||||
/*%
|
||||
* Adding any permission bits beyond 0x200 would mean typedef'ing
|
||||
* isc_fsaccess_t as isc_uint64_t, and redefining this value to
|
||||
* reflect the new range of permission types, Probably to 21 for
|
||||
* maximum flexibility. The number of bits has to accommodate all of
|
||||
* the permission types, and three full sets of them have to fit
|
||||
* within an isc_fsaccess_t.
|
||||
*/
|
||||
#define ISC__FSACCESS_PERMISSIONBITS 10
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
void
|
||||
isc_fsaccess_add(int trustee, int permission, isc_fsaccess_t *access);
|
||||
|
||||
void
|
||||
isc_fsaccess_remove(int trustee, int permission, isc_fsaccess_t *access);
|
||||
|
||||
isc_result_t
|
||||
isc_fsaccess_set(const char *path, isc_fsaccess_t access);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_FSACCESS_H */
|
||||
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2003 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: hash.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_HASH_H
|
||||
#define ISC_HASH_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/hash.h
|
||||
*
|
||||
* \brief The hash API
|
||||
* provides an unpredictable hash value for variable length data.
|
||||
* A hash object contains a random vector (which is hidden from clients
|
||||
* of this API) to make the actual hash value unpredictable.
|
||||
*
|
||||
* The algorithm used in the API guarantees the probability of hash
|
||||
* collision; in the current implementation, as long as the values stored
|
||||
* in the random vector are unpredictable, the probability of hash
|
||||
* collision between arbitrary two different values is at most 1/2^16.
|
||||
*
|
||||
* Although the API is generic about the hash keys, it mainly expects
|
||||
* DNS names (and sometimes IPv4/v6 addresses) as inputs. It has an
|
||||
* upper limit of the input length, and may run slow to calculate the
|
||||
* hash values for large inputs.
|
||||
*
|
||||
* This API is designed to be general so that it can provide multiple
|
||||
* different hash contexts that have different random vectors. However,
|
||||
* it should be typical to have a single context for an entire system.
|
||||
* To support such cases, the API also provides a single-context mode.
|
||||
*
|
||||
* \li MP:
|
||||
* The hash object is almost read-only. Once the internal random vector
|
||||
* is initialized, no write operation will occur, and there will be no
|
||||
* need to lock the object to calculate actual hash values.
|
||||
*
|
||||
* \li Reliability:
|
||||
* In some cases this module uses low-level data copy to initialize the
|
||||
* random vector. Errors in this part are likely to crash the server or
|
||||
* corrupt memory.
|
||||
*
|
||||
* \li Resources:
|
||||
* A buffer, used as a random vector for calculating hash values.
|
||||
*
|
||||
* \li Security:
|
||||
* This module intends to provide unpredictable hash values in
|
||||
* adversarial environments in order to avoid denial of service attacks
|
||||
* to hash buckets.
|
||||
* Its unpredictability relies on the quality of entropy to build the
|
||||
* random vector.
|
||||
*
|
||||
* \li Standards:
|
||||
* None.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports
|
||||
***/
|
||||
|
||||
#include <isc/types.h>
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
isc_hash_ctxcreate(isc_mem_t *mctx, isc_entropy_t *entropy, unsigned int limit,
|
||||
isc_hash_t **hctx);
|
||||
isc_result_t
|
||||
isc_hash_create(isc_mem_t *mctx, isc_entropy_t *entropy, size_t limit);
|
||||
/*!<
|
||||
* \brief Create a new hash object.
|
||||
*
|
||||
* isc_hash_ctxcreate() creates a different object.
|
||||
*
|
||||
* isc_hash_create() creates a module-internal object to support the
|
||||
* single-context mode. It should be called only once.
|
||||
*
|
||||
* 'entropy' must be NULL or a valid entropy object. If 'entropy' is NULL,
|
||||
* pseudo random values will be used to build the random vector, which may
|
||||
* weaken security.
|
||||
*
|
||||
* 'limit' specifies the maximum number of hash keys. If it is too large,
|
||||
* these functions may fail.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_hash_ctxattach(isc_hash_t *hctx, isc_hash_t **hctxp);
|
||||
/*!<
|
||||
* \brief Attach to a hash object.
|
||||
*
|
||||
* This function is only necessary for the multiple-context mode.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_hash_ctxdetach(isc_hash_t **hctxp);
|
||||
/*!<
|
||||
* \brief Detach from a hash object.
|
||||
*
|
||||
* This function is for the multiple-context mode, and takes a valid
|
||||
* hash object as an argument.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_hash_destroy(void);
|
||||
/*!<
|
||||
* \brief This function is for the single-context mode, and is expected to be used
|
||||
* as a counterpart of isc_hash_create().
|
||||
*
|
||||
* A valid module-internal hash object must have been created, and this
|
||||
* function should be called only once.
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
void
|
||||
isc_hash_ctxinit(isc_hash_t *hctx);
|
||||
void
|
||||
isc_hash_init(void);
|
||||
/*!<
|
||||
* \brief Initialize a hash object.
|
||||
*
|
||||
* It fills in the random vector with a proper
|
||||
* source of entropy, which is typically from the entropy object specified
|
||||
* at the creation. Thus, it is desirable to call these functions after
|
||||
* initializing the entropy object with some good entropy sources.
|
||||
*
|
||||
* These functions should be called before the first hash calculation.
|
||||
*
|
||||
* isc_hash_ctxinit() is for the multiple-context mode, and takes a valid hash
|
||||
* object as an argument.
|
||||
*
|
||||
* isc_hash_init() is for the single-context mode. A valid module-internal
|
||||
* hash object must have been created, and this function should be called only
|
||||
* once.
|
||||
*/
|
||||
/*@}*/
|
||||
|
||||
/*@{*/
|
||||
unsigned int
|
||||
isc_hash_ctxcalc(isc_hash_t *hctx, const unsigned char *key,
|
||||
unsigned int keylen, isc_boolean_t case_sensitive);
|
||||
unsigned int
|
||||
isc_hash_calc(const unsigned char *key, unsigned int keylen,
|
||||
isc_boolean_t case_sensitive);
|
||||
/*!<
|
||||
* \brief Calculate a hash value.
|
||||
*
|
||||
* isc_hash_ctxinit() is for the multiple-context mode, and takes a valid hash
|
||||
* object as an argument.
|
||||
*
|
||||
* isc_hash_init() is for the single-context mode. A valid module-internal
|
||||
* hash object must have been created.
|
||||
*
|
||||
* 'key' is the hash key, which is a variable length buffer.
|
||||
*
|
||||
* 'keylen' specifies the key length, which must not be larger than the limit
|
||||
* specified for the corresponding hash object.
|
||||
*
|
||||
* 'case_sensitive' specifies whether the hash key should be treated as
|
||||
* case_sensitive values. It should typically be ISC_FALSE if the hash key
|
||||
* is a DNS name.
|
||||
*/
|
||||
/*@}*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_HASH_H */
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1997-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: heap.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_HEAP_H
|
||||
#define ISC_HEAP_H 1
|
||||
|
||||
/*! \file isc/heap.h */
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*%
|
||||
* The comparison function returns ISC_TRUE if the first argument has
|
||||
* higher priority than the second argument, and ISC_FALSE otherwise.
|
||||
*/
|
||||
typedef isc_boolean_t (*isc_heapcompare_t)(void *, void *);
|
||||
|
||||
/*%
|
||||
* The index function allows the client of the heap to receive a callback
|
||||
* when an item's index number changes. This allows it to maintain
|
||||
* sync with its external state, but still delete itself, since deletions
|
||||
* from the heap require the index be provided.
|
||||
*/
|
||||
typedef void (*isc_heapindex_t)(void *, unsigned int);
|
||||
|
||||
/*%
|
||||
* The heapaction function is used when iterating over the heap.
|
||||
*
|
||||
* NOTE: The heap structure CANNOT BE MODIFIED during the call to
|
||||
* isc_heap_foreach().
|
||||
*/
|
||||
typedef void (*isc_heapaction_t)(void *, void *);
|
||||
|
||||
typedef struct isc_heap isc_heap_t;
|
||||
|
||||
isc_result_t
|
||||
isc_heap_create(isc_mem_t *mctx, isc_heapcompare_t compare,
|
||||
isc_heapindex_t index, unsigned int size_increment,
|
||||
isc_heap_t **heapp);
|
||||
/*!<
|
||||
* \brief Create a new heap. The heap is implemented using a space-efficient
|
||||
* storage method. When the heap elements are deleted space is not freed
|
||||
* but will be reused when new elements are inserted.
|
||||
*
|
||||
* Requires:
|
||||
*\li "mctx" is valid.
|
||||
*\li "compare" is a function which takes two void * arguments and
|
||||
* returns ISC_TRUE if the first argument has a higher priority than
|
||||
* the second, and ISC_FALSE otherwise.
|
||||
*\li "index" is a function which takes a void *, and an unsigned int
|
||||
* argument. This function will be called whenever an element's
|
||||
* index value changes, so it may continue to delete itself from the
|
||||
* heap. This option may be NULL if this functionality is unneeded.
|
||||
*\li "size_increment" is a hint about how large the heap should grow
|
||||
* when resizing is needed. If this is 0, a default size will be
|
||||
* used, which is currently 1024, allowing space for an additional 1024
|
||||
* heap elements to be inserted before adding more space.
|
||||
*\li "heapp" is not NULL, and "*heap" is NULL.
|
||||
*
|
||||
* Returns:
|
||||
*\li ISC_R_SUCCESS - success
|
||||
*\li ISC_R_NOMEMORY - insufficient memory
|
||||
*/
|
||||
|
||||
void
|
||||
isc_heap_destroy(isc_heap_t **heapp);
|
||||
/*!<
|
||||
* \brief Destroys a heap.
|
||||
*
|
||||
* Requires:
|
||||
*\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_heap_insert(isc_heap_t *heap, void *elt);
|
||||
/*!<
|
||||
* \brief Inserts a new element into a heap.
|
||||
*
|
||||
* Requires:
|
||||
*\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_heap_delete(isc_heap_t *heap, unsigned int index);
|
||||
/*!<
|
||||
* \brief Deletes an element from a heap, by element index.
|
||||
*
|
||||
* Requires:
|
||||
*\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t.
|
||||
*\li "index" is a valid element index, as provided by the "index" callback
|
||||
* provided during heap creation.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_heap_increased(isc_heap_t *heap, unsigned int index);
|
||||
/*!<
|
||||
* \brief Indicates to the heap that an element's priority has increased.
|
||||
* This function MUST be called whenever an element has increased in priority.
|
||||
*
|
||||
* Requires:
|
||||
*\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t.
|
||||
*\li "index" is a valid element index, as provided by the "index" callback
|
||||
* provided during heap creation.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_heap_decreased(isc_heap_t *heap, unsigned int index);
|
||||
/*!<
|
||||
* \brief Indicates to the heap that an element's priority has decreased.
|
||||
* This function MUST be called whenever an element has decreased in priority.
|
||||
*
|
||||
* Requires:
|
||||
*\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t.
|
||||
*\li "index" is a valid element index, as provided by the "index" callback
|
||||
* provided during heap creation.
|
||||
*/
|
||||
|
||||
void *
|
||||
isc_heap_element(isc_heap_t *heap, unsigned int index);
|
||||
/*!<
|
||||
* \brief Returns the element for a specific element index.
|
||||
*
|
||||
* Requires:
|
||||
*\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t.
|
||||
*\li "index" is a valid element index, as provided by the "index" callback
|
||||
* provided during heap creation.
|
||||
*
|
||||
* Returns:
|
||||
*\li A pointer to the element for the element index.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_heap_foreach(isc_heap_t *heap, isc_heapaction_t action, void *uap);
|
||||
/*!<
|
||||
* \brief Iterate over the heap, calling an action for each element. The
|
||||
* order of iteration is not sorted.
|
||||
*
|
||||
* Requires:
|
||||
*\li "heapp" is not NULL and "*heap" points to a valid isc_heap_t.
|
||||
*\li "action" is not NULL, and is a function which takes two arguments.
|
||||
* The first is a void *, representing the element, and the second is
|
||||
* "uap" as provided to isc_heap_foreach.
|
||||
*\li "uap" is a caller-provided argument, and may be NULL.
|
||||
*
|
||||
* Note:
|
||||
*\li The heap structure CANNOT be modified during this iteration. The only
|
||||
* safe function to call while iterating the heap is isc_heap_element().
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_HEAP_H */
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: hex.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_HEX_H
|
||||
#define ISC_HEX_H 1
|
||||
|
||||
/*! \file isc/hex.h */
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
isc_result_t
|
||||
isc_hex_totext(isc_region_t *source, int wordlength,
|
||||
const char *wordbreak, isc_buffer_t *target);
|
||||
/*!<
|
||||
* \brief Convert data into hex encoded text.
|
||||
*
|
||||
* Notes:
|
||||
*\li The hex encoded text in 'target' will be divided into
|
||||
* words of at most 'wordlength' characters, separated by
|
||||
* the 'wordbreak' string. No parentheses will surround
|
||||
* the text.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'source' is a region containing binary data
|
||||
*\li 'target' is a text buffer containing available space
|
||||
*\li 'wordbreak' points to a null-terminated string of
|
||||
* zero or more whitespace characters
|
||||
*
|
||||
* Ensures:
|
||||
*\li target will contain the hex encoded version of the data
|
||||
* in source. The 'used' pointer in target will be advanced as
|
||||
* necessary.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_hex_decodestring(const char *cstr, isc_buffer_t *target);
|
||||
/*!<
|
||||
* \brief Decode a null-terminated hex string.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'cstr' is non-null.
|
||||
*\li 'target' is a valid buffer.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS -- the entire decoded representation of 'cstring'
|
||||
* fit in 'target'.
|
||||
*\li #ISC_R_BADHEX -- 'cstr' is not a valid hex encoding.
|
||||
*
|
||||
* Other error returns are any possible error code from:
|
||||
* isc_lex_create(),
|
||||
* isc_lex_openbuffer(),
|
||||
* isc_hex_tobuffer().
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_hex_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length);
|
||||
/*!<
|
||||
* \brief Convert hex encoded text from a lexer context into data.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer context
|
||||
*\li 'target' is a buffer containing binary data
|
||||
*\li 'length' is an integer
|
||||
*
|
||||
* Ensures:
|
||||
*\li target will contain the data represented by the hex encoded
|
||||
* string parsed by the lexer. No more than length bytes will be read,
|
||||
* if length is positive. The 'used' pointer in target will be
|
||||
* advanced as necessary.
|
||||
*/
|
||||
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_HEX_H */
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: hmacmd5.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
/*! \file isc/hmacmd5.h
|
||||
* \brief This is the header file for the HMAC-MD5 keyed hash algorithm
|
||||
* described in RFC2104.
|
||||
*/
|
||||
|
||||
#ifndef ISC_HMACMD5_H
|
||||
#define ISC_HMACMD5_H 1
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/md5.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#define ISC_HMACMD5_KEYLENGTH 64
|
||||
|
||||
#ifdef ISC_PLATFORM_OPENSSLHASH
|
||||
#include <openssl/hmac.h>
|
||||
|
||||
typedef HMAC_CTX isc_hmacmd5_t;
|
||||
|
||||
#else
|
||||
|
||||
typedef struct {
|
||||
isc_md5_t md5ctx;
|
||||
unsigned char key[ISC_HMACMD5_KEYLENGTH];
|
||||
} isc_hmacmd5_t;
|
||||
#endif
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
void
|
||||
isc_hmacmd5_init(isc_hmacmd5_t *ctx, const unsigned char *key,
|
||||
unsigned int len);
|
||||
|
||||
void
|
||||
isc_hmacmd5_invalidate(isc_hmacmd5_t *ctx);
|
||||
|
||||
void
|
||||
isc_hmacmd5_update(isc_hmacmd5_t *ctx, const unsigned char *buf,
|
||||
unsigned int len);
|
||||
|
||||
void
|
||||
isc_hmacmd5_sign(isc_hmacmd5_t *ctx, unsigned char *digest);
|
||||
|
||||
isc_boolean_t
|
||||
isc_hmacmd5_verify(isc_hmacmd5_t *ctx, unsigned char *digest);
|
||||
|
||||
isc_boolean_t
|
||||
isc_hmacmd5_verify2(isc_hmacmd5_t *ctx, unsigned char *digest, size_t len);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_HMACMD5_H */
|
||||
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: hmacsha.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
/*! \file isc/hmacsha.h
|
||||
* This is the header file for the HMAC-SHA1, HMAC-SHA224, HMAC-SHA256,
|
||||
* HMAC-SHA334 and HMAC-SHA512 hash algorithm described in RFC 2104.
|
||||
*/
|
||||
|
||||
#ifndef ISC_HMACSHA_H
|
||||
#define ISC_HMACSHA_H 1
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/sha1.h>
|
||||
#include <isc/sha2.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#define ISC_HMACSHA1_KEYLENGTH ISC_SHA1_BLOCK_LENGTH
|
||||
#define ISC_HMACSHA224_KEYLENGTH ISC_SHA224_BLOCK_LENGTH
|
||||
#define ISC_HMACSHA256_KEYLENGTH ISC_SHA256_BLOCK_LENGTH
|
||||
#define ISC_HMACSHA384_KEYLENGTH ISC_SHA384_BLOCK_LENGTH
|
||||
#define ISC_HMACSHA512_KEYLENGTH ISC_SHA512_BLOCK_LENGTH
|
||||
|
||||
#ifdef ISC_PLATFORM_OPENSSLHASH
|
||||
#include <openssl/hmac.h>
|
||||
|
||||
typedef HMAC_CTX isc_hmacsha1_t;
|
||||
typedef HMAC_CTX isc_hmacsha224_t;
|
||||
typedef HMAC_CTX isc_hmacsha256_t;
|
||||
typedef HMAC_CTX isc_hmacsha384_t;
|
||||
typedef HMAC_CTX isc_hmacsha512_t;
|
||||
|
||||
#else
|
||||
|
||||
typedef struct {
|
||||
isc_sha1_t sha1ctx;
|
||||
unsigned char key[ISC_HMACSHA1_KEYLENGTH];
|
||||
} isc_hmacsha1_t;
|
||||
|
||||
typedef struct {
|
||||
isc_sha224_t sha224ctx;
|
||||
unsigned char key[ISC_HMACSHA224_KEYLENGTH];
|
||||
} isc_hmacsha224_t;
|
||||
|
||||
typedef struct {
|
||||
isc_sha256_t sha256ctx;
|
||||
unsigned char key[ISC_HMACSHA256_KEYLENGTH];
|
||||
} isc_hmacsha256_t;
|
||||
|
||||
typedef struct {
|
||||
isc_sha384_t sha384ctx;
|
||||
unsigned char key[ISC_HMACSHA384_KEYLENGTH];
|
||||
} isc_hmacsha384_t;
|
||||
|
||||
typedef struct {
|
||||
isc_sha512_t sha512ctx;
|
||||
unsigned char key[ISC_HMACSHA512_KEYLENGTH];
|
||||
} isc_hmacsha512_t;
|
||||
#endif
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
void
|
||||
isc_hmacsha1_init(isc_hmacsha1_t *ctx, const unsigned char *key,
|
||||
unsigned int len);
|
||||
|
||||
void
|
||||
isc_hmacsha1_invalidate(isc_hmacsha1_t *ctx);
|
||||
|
||||
void
|
||||
isc_hmacsha1_update(isc_hmacsha1_t *ctx, const unsigned char *buf,
|
||||
unsigned int len);
|
||||
|
||||
void
|
||||
isc_hmacsha1_sign(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len);
|
||||
|
||||
isc_boolean_t
|
||||
isc_hmacsha1_verify(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len);
|
||||
|
||||
|
||||
void
|
||||
isc_hmacsha224_init(isc_hmacsha224_t *ctx, const unsigned char *key,
|
||||
unsigned int len);
|
||||
|
||||
void
|
||||
isc_hmacsha224_invalidate(isc_hmacsha224_t *ctx);
|
||||
|
||||
void
|
||||
isc_hmacsha224_update(isc_hmacsha224_t *ctx, const unsigned char *buf,
|
||||
unsigned int len);
|
||||
|
||||
void
|
||||
isc_hmacsha224_sign(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len);
|
||||
|
||||
isc_boolean_t
|
||||
isc_hmacsha224_verify(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len);
|
||||
|
||||
|
||||
void
|
||||
isc_hmacsha256_init(isc_hmacsha256_t *ctx, const unsigned char *key,
|
||||
unsigned int len);
|
||||
|
||||
void
|
||||
isc_hmacsha256_invalidate(isc_hmacsha256_t *ctx);
|
||||
|
||||
void
|
||||
isc_hmacsha256_update(isc_hmacsha256_t *ctx, const unsigned char *buf,
|
||||
unsigned int len);
|
||||
|
||||
void
|
||||
isc_hmacsha256_sign(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len);
|
||||
|
||||
isc_boolean_t
|
||||
isc_hmacsha256_verify(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len);
|
||||
|
||||
|
||||
void
|
||||
isc_hmacsha384_init(isc_hmacsha384_t *ctx, const unsigned char *key,
|
||||
unsigned int len);
|
||||
|
||||
void
|
||||
isc_hmacsha384_invalidate(isc_hmacsha384_t *ctx);
|
||||
|
||||
void
|
||||
isc_hmacsha384_update(isc_hmacsha384_t *ctx, const unsigned char *buf,
|
||||
unsigned int len);
|
||||
|
||||
void
|
||||
isc_hmacsha384_sign(isc_hmacsha384_t *ctx, unsigned char *digest, size_t len);
|
||||
|
||||
isc_boolean_t
|
||||
isc_hmacsha384_verify(isc_hmacsha384_t *ctx, unsigned char *digest, size_t len);
|
||||
|
||||
|
||||
void
|
||||
isc_hmacsha512_init(isc_hmacsha512_t *ctx, const unsigned char *key,
|
||||
unsigned int len);
|
||||
|
||||
void
|
||||
isc_hmacsha512_invalidate(isc_hmacsha512_t *ctx);
|
||||
|
||||
void
|
||||
isc_hmacsha512_update(isc_hmacsha512_t *ctx, const unsigned char *buf,
|
||||
unsigned int len);
|
||||
|
||||
void
|
||||
isc_hmacsha512_sign(isc_hmacsha512_t *ctx, unsigned char *digest, size_t len);
|
||||
|
||||
isc_boolean_t
|
||||
isc_hmacsha512_verify(isc_hmacsha512_t *ctx, unsigned char *digest, size_t len);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_HMACSHA_H */
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2006-2008 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: httpd.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_HTTPD_H
|
||||
#define ISC_HTTPD_H 1
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <isc/event.h>
|
||||
#include <isc/eventclass.h>
|
||||
#include <isc/types.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/task.h>
|
||||
|
||||
#define HTTPD_EVENTCLASS ISC_EVENTCLASS(4300)
|
||||
#define HTTPD_SHUTDOWN (HTTPD_EVENTCLASS + 0x0001)
|
||||
|
||||
#define ISC_HTTPDMGR_FLAGSHUTTINGDOWN 0x00000001
|
||||
|
||||
/*
|
||||
* Create a new http daemon which will send, once every time period,
|
||||
* a http-like header followed by HTTP data.
|
||||
*/
|
||||
isc_result_t
|
||||
isc_httpdmgr_create(isc_mem_t *mctx, isc_socket_t *sock, isc_task_t *task,
|
||||
isc_httpdclientok_t *client_ok,
|
||||
isc_httpdondestroy_t *ondestory, void *cb_arg,
|
||||
isc_timermgr_t *tmgr, isc_httpdmgr_t **httpdp);
|
||||
|
||||
void
|
||||
isc_httpdmgr_shutdown(isc_httpdmgr_t **httpdp);
|
||||
|
||||
isc_result_t
|
||||
isc_httpdmgr_addurl(isc_httpdmgr_t *httpdmgr, const char *url,
|
||||
isc_httpdaction_t *func, void *arg);
|
||||
|
||||
isc_result_t
|
||||
isc_httpd_response(isc_httpd_t *httpd);
|
||||
|
||||
isc_result_t
|
||||
isc_httpd_addheader(isc_httpd_t *httpd, const char *name,
|
||||
const char *val);
|
||||
|
||||
isc_result_t
|
||||
isc_httpd_addheaderuint(isc_httpd_t *httpd, const char *name, int val);
|
||||
|
||||
isc_result_t isc_httpd_endheaders(isc_httpd_t *httpd);
|
||||
|
||||
#endif /* ISC_HTTPD_H */
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: int.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_INT_H
|
||||
#define ISC_INT_H 1
|
||||
|
||||
/*! \file */
|
||||
|
||||
typedef char isc_int8_t;
|
||||
typedef unsigned char isc_uint8_t;
|
||||
typedef short isc_int16_t;
|
||||
typedef unsigned short isc_uint16_t;
|
||||
typedef int isc_int32_t;
|
||||
typedef unsigned int isc_uint32_t;
|
||||
typedef long long isc_int64_t;
|
||||
typedef unsigned long long isc_uint64_t;
|
||||
|
||||
#define ISC_INT8_MIN -128
|
||||
#define ISC_INT8_MAX 127
|
||||
#define ISC_UINT8_MAX 255
|
||||
|
||||
#define ISC_INT16_MIN -32768
|
||||
#define ISC_INT16_MAX 32767
|
||||
#define ISC_UINT16_MAX 65535
|
||||
|
||||
/*%
|
||||
* Note that "int" is 32 bits on all currently supported Unix-like operating
|
||||
* systems, but "long" can be either 32 bits or 64 bits, thus the 32 bit
|
||||
* constants are not qualified with "L".
|
||||
*/
|
||||
#define ISC_INT32_MIN -2147483648
|
||||
#define ISC_INT32_MAX 2147483647
|
||||
#define ISC_UINT32_MAX 4294967295U
|
||||
|
||||
#define ISC_INT64_MIN -9223372036854775808LL
|
||||
#define ISC_INT64_MAX 9223372036854775807LL
|
||||
#define ISC_UINT64_MAX 18446744073709551615ULL
|
||||
|
||||
#endif /* ISC_INT_H */
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: interfaceiter.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_INTERFACEITER_H
|
||||
#define ISC_INTERFACEITER_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/interfaceiter.h
|
||||
* \brief Iterates over the list of network interfaces.
|
||||
*
|
||||
* Interfaces whose address family is not supported are ignored and never
|
||||
* returned by the iterator. Interfaces whose netmask, interface flags,
|
||||
* or similar cannot be obtained are also ignored, and the failure is logged.
|
||||
*
|
||||
* Standards:
|
||||
* The API for scanning varies greatly among operating systems.
|
||||
* This module attempts to hide the differences.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports
|
||||
***/
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/netaddr.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/*!
|
||||
* \brief Public structure describing a network interface.
|
||||
*/
|
||||
|
||||
struct isc_interface {
|
||||
char name[32]; /*%< Interface name, null-terminated. */
|
||||
unsigned int af; /*%< Address family. */
|
||||
isc_netaddr_t address; /*%< Local address. */
|
||||
isc_netaddr_t netmask; /*%< Network mask. */
|
||||
isc_netaddr_t broadcast; /*&< Broadcast address. */
|
||||
isc_netaddr_t dstaddress; /*%< Destination address (point-to-point only). */
|
||||
isc_uint32_t flags; /*%< Flags; see INTERFACE flags. */
|
||||
unsigned int ifindex; /*%< Interface index for IP(V6)_MULTICAST_IF. */
|
||||
};
|
||||
|
||||
/*@{*/
|
||||
/*! Interface flags. */
|
||||
|
||||
#define INTERFACE_F_UP 0x00000001U
|
||||
#define INTERFACE_F_POINTTOPOINT 0x00000002U
|
||||
#define INTERFACE_F_LOOPBACK 0x00000004U
|
||||
#define INTERFACE_F_BROADCAST 0x00000008U
|
||||
#define INTERFACE_F_MULTICAST 0x00000010U
|
||||
#define INTERFACE_F_PRIVACY 0x00000020U /* RFC 4941 */
|
||||
/*@}*/
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp);
|
||||
/*!<
|
||||
* \brief Create an iterator for traversing the operating system's list
|
||||
* of network interfaces.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
* \li #ISC_R_NOMEMORY
|
||||
*\li Various network-related errors
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_interfaceiter_first(isc_interfaceiter_t *iter);
|
||||
/*!<
|
||||
* \brief Position the iterator on the first interface.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS Success.
|
||||
*\li #ISC_R_NOMORE There are no interfaces.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_interfaceiter_current(isc_interfaceiter_t *iter,
|
||||
isc_interface_t *ifdata);
|
||||
/*!<
|
||||
* \brief Get information about the interface the iterator is currently
|
||||
* positioned at and store it at *ifdata.
|
||||
*
|
||||
* Requires:
|
||||
*\li The iterator has been successfully positioned using
|
||||
* isc_interface_iter_first() / isc_interface_iter_next().
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS Success.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_interfaceiter_next(isc_interfaceiter_t *iter);
|
||||
/*!<
|
||||
* \brief Position the iterator on the next interface.
|
||||
*
|
||||
* Requires:
|
||||
* \li The iterator has been successfully positioned using
|
||||
* isc_interface_iter_first() / isc_interface_iter_next().
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS Success.
|
||||
*\li #ISC_R_NOMORE There are no more interfaces.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_interfaceiter_destroy(isc_interfaceiter_t **iterp);
|
||||
/*!<
|
||||
* \brief Destroy the iterator.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_INTERFACEITER_H */
|
||||
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2002 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: ipv6.h,v 1.1.12.2 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_IPV6_H
|
||||
#define ISC_IPV6_H 1
|
||||
|
||||
/*!
|
||||
* Also define LWRES_IPV6_H to keep it from being included if liblwres is
|
||||
* being used, or redefinition errors will occur.
|
||||
*/
|
||||
#define LWRES_IPV6_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/ipv6.h
|
||||
* \brief IPv6 definitions for systems which do not support IPv6.
|
||||
*
|
||||
* \li MP:
|
||||
* No impact.
|
||||
*
|
||||
* \li Reliability:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Resources:
|
||||
* N/A.
|
||||
*
|
||||
* \li Security:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Standards:
|
||||
* RFC2553.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports.
|
||||
***/
|
||||
|
||||
#include <isc/int.h>
|
||||
#include <isc/platform.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/***
|
||||
*** Types.
|
||||
***/
|
||||
/*
|
||||
* We probably don't need this on NTP
|
||||
*/
|
||||
#ifdef ISC_ONLY_IPV6
|
||||
|
||||
struct in6_addr {
|
||||
union {
|
||||
isc_uint8_t _S6_u8[16];
|
||||
isc_uint16_t _S6_u16[8];
|
||||
isc_uint32_t _S6_u32[4];
|
||||
} _S6_un;
|
||||
};
|
||||
#define s6_addr _S6_un._S6_u8
|
||||
#define s6_addr8 _S6_un._S6_u8
|
||||
#define s6_addr16 _S6_un._S6_u16
|
||||
#define s6_addr32 _S6_un._S6_u32
|
||||
|
||||
#define IN6ADDR_ANY_INIT {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}}
|
||||
#define IN6ADDR_LOOPBACK_INIT {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}}
|
||||
|
||||
LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_any;
|
||||
LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_loopback;
|
||||
|
||||
struct sockaddr_in6 {
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
isc_uint8_t sin6_len;
|
||||
isc_uint8_t sin6_family;
|
||||
#else
|
||||
isc_uint16_t sin6_family;
|
||||
#endif
|
||||
isc_uint16_t sin6_port;
|
||||
isc_uint32_t sin6_flowinfo;
|
||||
struct in6_addr sin6_addr;
|
||||
isc_uint32_t sin6_scope_id;
|
||||
};
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVESALEN
|
||||
#define SIN6_LEN 1
|
||||
#endif
|
||||
|
||||
/*%
|
||||
* Unspecified
|
||||
*/
|
||||
#define IN6_IS_ADDR_UNSPECIFIED(a) \
|
||||
(((a)->s6_addr32[0] == 0) && \
|
||||
((a)->s6_addr32[1] == 0) && \
|
||||
((a)->s6_addr32[2] == 0) && \
|
||||
((a)->s6_addr32[3] == 0))
|
||||
|
||||
/*%
|
||||
* Loopback
|
||||
*/
|
||||
#define IN6_IS_ADDR_LOOPBACK(a) \
|
||||
(((a)->s6_addr32[0] == 0) && \
|
||||
((a)->s6_addr32[1] == 0) && \
|
||||
((a)->s6_addr32[2] == 0) && \
|
||||
((a)->s6_addr32[3] == htonl(1)))
|
||||
|
||||
/*%
|
||||
* IPv4 compatible
|
||||
*/
|
||||
#define IN6_IS_ADDR_V4COMPAT(a) \
|
||||
(((a)->s6_addr32[0] == 0) && \
|
||||
((a)->s6_addr32[1] == 0) && \
|
||||
((a)->s6_addr32[2] == 0) && \
|
||||
((a)->s6_addr32[3] != 0) && \
|
||||
((a)->s6_addr32[3] != htonl(1)))
|
||||
|
||||
/*%
|
||||
* Mapped
|
||||
*/
|
||||
#define IN6_IS_ADDR_V4MAPPED(a) \
|
||||
(((a)->s6_addr32[0] == 0) && \
|
||||
((a)->s6_addr32[1] == 0) && \
|
||||
((a)->s6_addr32[2] == htonl(0x0000ffff)))
|
||||
|
||||
/*%
|
||||
* Multicast
|
||||
*/
|
||||
#define IN6_IS_ADDR_MULTICAST(a) \
|
||||
((a)->s6_addr8[0] == 0xffU)
|
||||
|
||||
/*%
|
||||
* Unicast link / site local.
|
||||
*/
|
||||
#define IN6_IS_ADDR_LINKLOCAL(a) \
|
||||
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
|
||||
#define IN6_IS_ADDR_SITELOCAL(a) \
|
||||
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
|
||||
#endif /* ISC_ONLY_IPV6 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* ISC_IPV6_H */
|
||||
@@ -0,0 +1,904 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2008, 2010 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2002 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: isc_buffer.h,v 1.1.10.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_BUFFER_H
|
||||
#define ISC_BUFFER_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/buffer.h
|
||||
*
|
||||
* \brief A buffer is a region of memory, together with a set of related subregions.
|
||||
* Buffers are used for parsing and I/O operations.
|
||||
*
|
||||
* The 'used region' and the 'available' region are disjoint, and their
|
||||
* union is the buffer's region. The used region extends from the beginning
|
||||
* of the buffer region to the last used byte. The available region
|
||||
* extends from one byte greater than the last used byte to the end of the
|
||||
* buffer's region. The size of the used region can be changed using various
|
||||
* buffer commands. Initially, the used region is empty.
|
||||
*
|
||||
* The used region is further subdivided into two disjoint regions: the
|
||||
* 'consumed region' and the 'remaining region'. The union of these two
|
||||
* regions is the used region. The consumed region extends from the beginning
|
||||
* of the used region to the byte before the 'current' offset (if any). The
|
||||
* 'remaining' region the current pointer to the end of the used
|
||||
* region. The size of the consumed region can be changed using various
|
||||
* buffer commands. Initially, the consumed region is empty.
|
||||
*
|
||||
* The 'active region' is an (optional) subregion of the remaining region.
|
||||
* It extends from the current offset to an offset in the remaining region
|
||||
* that is selected with isc_buffer_setactive(). Initially, the active region
|
||||
* is empty. If the current offset advances beyond the chosen offset, the
|
||||
* active region will also be empty.
|
||||
*
|
||||
* \verbatim
|
||||
* /------------entire length---------------\
|
||||
* /----- used region -----\/-- available --\
|
||||
* +----------------------------------------+
|
||||
* | consumed | remaining | |
|
||||
* +----------------------------------------+
|
||||
* a b c d e
|
||||
*
|
||||
* a == base of buffer.
|
||||
* b == current pointer. Can be anywhere between a and d.
|
||||
* c == active pointer. Meaningful between b and d.
|
||||
* d == used pointer.
|
||||
* e == length of buffer.
|
||||
*
|
||||
* a-e == entire length of buffer.
|
||||
* a-d == used region.
|
||||
* a-b == consumed region.
|
||||
* b-d == remaining region.
|
||||
* b-c == optional active region.
|
||||
*\endverbatim
|
||||
*
|
||||
* The following invariants are maintained by all routines:
|
||||
*
|
||||
*\code
|
||||
* length > 0
|
||||
*
|
||||
* base is a valid pointer to length bytes of memory
|
||||
*
|
||||
* 0 <= used <= length
|
||||
*
|
||||
* 0 <= current <= used
|
||||
*
|
||||
* 0 <= active <= used
|
||||
* (although active < current implies empty active region)
|
||||
*\endcode
|
||||
*
|
||||
* \li MP:
|
||||
* Buffers have no synchronization. Clients must ensure exclusive
|
||||
* access.
|
||||
*
|
||||
* \li Reliability:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Resources:
|
||||
* Memory: 1 pointer + 6 unsigned integers per buffer.
|
||||
*
|
||||
* \li Security:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Standards:
|
||||
* None.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports
|
||||
***/
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/magic.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/*!
|
||||
* To make many functions be inline macros (via \#define) define this.
|
||||
* If it is undefined, a function will be used.
|
||||
*/
|
||||
/* #define ISC_BUFFER_USEINLINE */
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*@{*/
|
||||
/*!
|
||||
*** Magic numbers
|
||||
***/
|
||||
#define ISC_BUFFER_MAGIC 0x42756621U /* Buf!. */
|
||||
#define ISC_BUFFER_VALID(b) ISC_MAGIC_VALID(b, ISC_BUFFER_MAGIC)
|
||||
/*@}*/
|
||||
|
||||
/*
|
||||
* The following macros MUST be used only on valid buffers. It is the
|
||||
* caller's responsibility to ensure this by using the ISC_BUFFER_VALID
|
||||
* check above, or by calling another isc_buffer_*() function (rather than
|
||||
* another macro.)
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
/*!
|
||||
* Fundamental buffer elements. (A through E in the introductory comment.)
|
||||
*/
|
||||
#define isc_buffer_base(b) ((void *)(b)->base) /*a*/
|
||||
#define isc_buffer_current(b) \
|
||||
((void *)((unsigned char *)(b)->base + (b)->current)) /*b*/
|
||||
#define isc_buffer_active(b) \
|
||||
((void *)((unsigned char *)(b)->base + (b)->active)) /*c*/
|
||||
#define isc_buffer_used(b) \
|
||||
((void *)((unsigned char *)(b)->base + (b)->used)) /*d*/
|
||||
#define isc_buffer_length(b) ((b)->length) /*e*/
|
||||
/*@}*/
|
||||
|
||||
/*@{*/
|
||||
/*!
|
||||
* Derived lengths. (Described in the introductory comment.)
|
||||
*/
|
||||
#define isc_buffer_usedlength(b) ((b)->used) /* d-a */
|
||||
#define isc_buffer_consumedlength(b) ((b)->current) /* b-a */
|
||||
#define isc_buffer_remaininglength(b) ((b)->used - (b)->current) /* d-b */
|
||||
#define isc_buffer_activelength(b) ((b)->active - (b)->current) /* c-b */
|
||||
#define isc_buffer_availablelength(b) ((b)->length - (b)->used) /* e-d */
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* Note that the buffer structure is public. This is principally so buffer
|
||||
* operations can be implemented using macros. Applications are strongly
|
||||
* discouraged from directly manipulating the structure.
|
||||
*/
|
||||
|
||||
struct isc_buffer {
|
||||
unsigned int magic;
|
||||
void *base;
|
||||
/*@{*/
|
||||
/*! The following integers are byte offsets from 'base'. */
|
||||
unsigned int length;
|
||||
unsigned int used;
|
||||
unsigned int current;
|
||||
unsigned int active;
|
||||
/*@}*/
|
||||
/*! linkable */
|
||||
ISC_LINK(isc_buffer_t) link;
|
||||
/*! private internal elements */
|
||||
isc_mem_t *mctx;
|
||||
};
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
isc_result_t
|
||||
isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer,
|
||||
unsigned int length);
|
||||
/*!<
|
||||
* \brief Allocate a dynamic linkable buffer which has "length" bytes in the
|
||||
* data region.
|
||||
*
|
||||
* Requires:
|
||||
*\li "mctx" is valid.
|
||||
*
|
||||
*\li "dynbuffer" is non-NULL, and "*dynbuffer" is NULL.
|
||||
*
|
||||
* Returns:
|
||||
*\li ISC_R_SUCCESS - success
|
||||
*\li ISC_R_NOMEMORY - no memory available
|
||||
*
|
||||
* Note:
|
||||
*\li Changing the buffer's length field is not permitted.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_buffer_free(isc_buffer_t **dynbuffer);
|
||||
/*!<
|
||||
* \brief Release resources allocated for a dynamic buffer.
|
||||
*
|
||||
* Requires:
|
||||
*\li "dynbuffer" is not NULL.
|
||||
*
|
||||
*\li "*dynbuffer" is a valid dynamic buffer.
|
||||
*
|
||||
* Ensures:
|
||||
*\li "*dynbuffer" will be NULL on return, and all memory associated with
|
||||
* the dynamic buffer is returned to the memory context used in
|
||||
* isc_buffer_allocate().
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_init(isc_buffer_t *b, const void *base, unsigned int length);
|
||||
/*!<
|
||||
* \brief Make 'b' refer to the 'length'-byte region starting at base.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'length' > 0
|
||||
*
|
||||
*\li 'base' is a pointer to a sequence of 'length' bytes.
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_initnull(isc_buffer_t *b);
|
||||
/*!<
|
||||
*\brief Initialize a buffer 'b' with a null data and zero length/
|
||||
*/
|
||||
|
||||
void
|
||||
isc_buffer_reinit(isc_buffer_t *b, void *base, unsigned int length);
|
||||
/*!<
|
||||
* \brief Make 'b' refer to the 'length'-byte region starting at base.
|
||||
* Any existing data will be copied.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'length' > 0 AND length >= previous length
|
||||
*
|
||||
*\li 'base' is a pointer to a sequence of 'length' bytes.
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_invalidate(isc_buffer_t *b);
|
||||
/*!<
|
||||
* \brief Make 'b' an invalid buffer.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
* Ensures:
|
||||
*\li If assertion checking is enabled, future attempts to use 'b' without
|
||||
* calling isc_buffer_init() on it will cause an assertion failure.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_region(isc_buffer_t *b, isc_region_t *r);
|
||||
/*!<
|
||||
* \brief Make 'r' refer to the region of 'b'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li 'r' points to a region structure.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_usedregion(isc_buffer_t *b, isc_region_t *r);
|
||||
/*!<
|
||||
* \brief Make 'r' refer to the used region of 'b'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li 'r' points to a region structure.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_availableregion(isc_buffer_t *b, isc_region_t *r);
|
||||
/*!<
|
||||
* \brief Make 'r' refer to the available region of 'b'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li 'r' points to a region structure.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_add(isc_buffer_t *b, unsigned int n);
|
||||
/*!<
|
||||
* \brief Increase the 'used' region of 'b' by 'n' bytes.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer
|
||||
*
|
||||
*\li used + n <= length
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_subtract(isc_buffer_t *b, unsigned int n);
|
||||
/*!<
|
||||
* \brief Decrease the 'used' region of 'b' by 'n' bytes.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer
|
||||
*
|
||||
*\li used >= n
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_clear(isc_buffer_t *b);
|
||||
/*!<
|
||||
* \brief Make the used region empty.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li used = 0
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_consumedregion(isc_buffer_t *b, isc_region_t *r);
|
||||
/*!<
|
||||
* \brief Make 'r' refer to the consumed region of 'b'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li 'r' points to a region structure.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_remainingregion(isc_buffer_t *b, isc_region_t *r);
|
||||
/*!<
|
||||
* \brief Make 'r' refer to the remaining region of 'b'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li 'r' points to a region structure.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_activeregion(isc_buffer_t *b, isc_region_t *r);
|
||||
/*!<
|
||||
* \brief Make 'r' refer to the active region of 'b'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li 'r' points to a region structure.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_setactive(isc_buffer_t *b, unsigned int n);
|
||||
/*!<
|
||||
* \brief Sets the end of the active region 'n' bytes after current.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li current + n <= used
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_first(isc_buffer_t *b);
|
||||
/*!<
|
||||
* \brief Make the consumed region empty.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li current == 0
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_forward(isc_buffer_t *b, unsigned int n);
|
||||
/*!<
|
||||
* \brief Increase the 'consumed' region of 'b' by 'n' bytes.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer
|
||||
*
|
||||
*\li current + n <= used
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_back(isc_buffer_t *b, unsigned int n);
|
||||
/*!<
|
||||
* \brief Decrease the 'consumed' region of 'b' by 'n' bytes.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer
|
||||
*
|
||||
*\li n <= current
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
isc_buffer_compact(isc_buffer_t *b);
|
||||
/*!<
|
||||
* \brief Compact the used region by moving the remaining region so it occurs
|
||||
* at the start of the buffer. The used region is shrunk by the size of
|
||||
* the consumed region, and the consumed region is then made empty.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li current == 0
|
||||
*
|
||||
*\li The size of the used region is now equal to the size of the remaining
|
||||
* region (as it was before the call). The contents of the used region
|
||||
* are those of the remaining region (as it was before the call).
|
||||
*/
|
||||
|
||||
isc_uint8_t
|
||||
isc_buffer_getuint8(isc_buffer_t *b);
|
||||
/*!<
|
||||
* \brief Read an unsigned 8-bit integer from 'b' and return it.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li The length of the available region of 'b' is at least 1.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li The current pointer in 'b' is advanced by 1.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li A 8-bit unsigned integer.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_putuint8(isc_buffer_t *b, isc_uint8_t val);
|
||||
/*!<
|
||||
* \brief Store an unsigned 8-bit integer from 'val' into 'b'.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li The length of the unused region of 'b' is at least 1.
|
||||
*
|
||||
* Ensures:
|
||||
*\li The used pointer in 'b' is advanced by 1.
|
||||
*/
|
||||
|
||||
isc_uint16_t
|
||||
isc_buffer_getuint16(isc_buffer_t *b);
|
||||
/*!<
|
||||
* \brief Read an unsigned 16-bit integer in network byte order from 'b', convert
|
||||
* it to host byte order, and return it.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li The length of the available region of 'b' is at least 2.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li The current pointer in 'b' is advanced by 2.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li A 16-bit unsigned integer.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_putuint16(isc_buffer_t *b, isc_uint16_t val);
|
||||
/*!<
|
||||
* \brief Store an unsigned 16-bit integer in host byte order from 'val'
|
||||
* into 'b' in network byte order.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li The length of the unused region of 'b' is at least 2.
|
||||
*
|
||||
* Ensures:
|
||||
*\li The used pointer in 'b' is advanced by 2.
|
||||
*/
|
||||
|
||||
isc_uint32_t
|
||||
isc_buffer_getuint32(isc_buffer_t *b);
|
||||
/*!<
|
||||
* \brief Read an unsigned 32-bit integer in network byte order from 'b', convert
|
||||
* it to host byte order, and return it.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li The length of the available region of 'b' is at least 4.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li The current pointer in 'b' is advanced by 4.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li A 32-bit unsigned integer.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_putuint32(isc_buffer_t *b, isc_uint32_t val);
|
||||
/*!<
|
||||
* \brief Store an unsigned 32-bit integer in host byte order from 'val'
|
||||
* into 'b' in network byte order.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li The length of the unused region of 'b' is at least 4.
|
||||
*
|
||||
* Ensures:
|
||||
*\li The used pointer in 'b' is advanced by 4.
|
||||
*/
|
||||
|
||||
isc_uint64_t
|
||||
isc_buffer_getuint48(isc_buffer_t *b);
|
||||
/*!<
|
||||
* \brief Read an unsigned 48-bit integer in network byte order from 'b',
|
||||
* convert it to host byte order, and return it.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li The length of the available region of 'b' is at least 6.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li The current pointer in 'b' is advanced by 6.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li A 48-bit unsigned integer (stored in a 64-bit integer).
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_putuint48(isc_buffer_t *b, isc_uint64_t val);
|
||||
/*!<
|
||||
* \brief Store an unsigned 48-bit integer in host byte order from 'val'
|
||||
* into 'b' in network byte order.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li The length of the unused region of 'b' is at least 6.
|
||||
*
|
||||
* Ensures:
|
||||
*\li The used pointer in 'b' is advanced by 6.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_putuint24(isc_buffer_t *b, isc_uint32_t val);
|
||||
/*!<
|
||||
* Store an unsigned 24-bit integer in host byte order from 'val'
|
||||
* into 'b' in network byte order.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
* The length of the unused region of 'b' is at least 3.
|
||||
*
|
||||
* Ensures:
|
||||
*\li The used pointer in 'b' is advanced by 3.
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_putmem(isc_buffer_t *b, const unsigned char *base,
|
||||
unsigned int length);
|
||||
/*!<
|
||||
* \brief Copy 'length' bytes of memory at 'base' into 'b'.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li 'base' points to 'length' bytes of valid memory.
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
isc__buffer_putstr(isc_buffer_t *b, const char *source);
|
||||
/*!<
|
||||
* \brief Copy 'source' into 'b', not including terminating NUL.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li 'source' to be a valid NULL terminated string.
|
||||
*
|
||||
*\li strlen(source) <= isc_buffer_available(b)
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r);
|
||||
/*!<
|
||||
* \brief Copy the contents of 'r' into 'b'.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'b' is a valid buffer.
|
||||
*
|
||||
*\li 'r' is a valid region.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li ISC_R_SUCCESS
|
||||
*\li ISC_R_NOSPACE The available region of 'b' is not
|
||||
* big enough.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
/*
|
||||
* Inline macro versions of the functions. These should never be called
|
||||
* directly by an application, but will be used by the functions within
|
||||
* buffer.c. The callers should always use "isc_buffer_*()" names, never
|
||||
* ones beginning with "isc__"
|
||||
*/
|
||||
|
||||
/*! \note
|
||||
* XXXDCL Something more could be done with initializing buffers that
|
||||
* point to const data. For example, a new function, isc_buffer_initconst,
|
||||
* could be used, and a new boolean flag in the buffer structure could
|
||||
* indicate whether the buffer was initialized with that function.
|
||||
* (isc_bufer_init itself would be reprototyped to *not* have its "base"
|
||||
* parameter be const.) Then if the boolean were true, the isc_buffer_put*
|
||||
* functions could assert a contractual requirement for a non-const buffer.
|
||||
* One drawback is that the isc_buffer_* functions (macros) that return
|
||||
* pointers would still need to return non-const pointers to avoid compiler
|
||||
* warnings, so it would be up to code that uses them to have to deal
|
||||
* with the possibility that the buffer was initialized as const --
|
||||
* a problem that they *already* have to deal with but have absolutely
|
||||
* no ability to. With a new isc_buffer_isconst() function returning
|
||||
* true/false, they could at least assert a contractual requirement for
|
||||
* non-const buffers when needed.
|
||||
*/
|
||||
#define ISC__BUFFER_INIT(_b, _base, _length) \
|
||||
do { \
|
||||
union { \
|
||||
const void * konst; \
|
||||
void * var; \
|
||||
} _u; \
|
||||
_u.konst = (_base); \
|
||||
(_b)->base = _u.var; \
|
||||
(_b)->length = (_length); \
|
||||
(_b)->used = 0; \
|
||||
(_b)->current = 0; \
|
||||
(_b)->active = 0; \
|
||||
(_b)->mctx = NULL; \
|
||||
ISC_LINK_INIT(_b, link); \
|
||||
(_b)->magic = ISC_BUFFER_MAGIC; \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_INITNULL(_b) ISC__BUFFER_INIT(_b, NULL, 0)
|
||||
|
||||
#define ISC__BUFFER_INVALIDATE(_b) \
|
||||
do { \
|
||||
(_b)->magic = 0; \
|
||||
(_b)->base = NULL; \
|
||||
(_b)->length = 0; \
|
||||
(_b)->used = 0; \
|
||||
(_b)->current = 0; \
|
||||
(_b)->active = 0; \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_REGION(_b, _r) \
|
||||
do { \
|
||||
(_r)->base = (_b)->base; \
|
||||
(_r)->length = (_b)->length; \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_USEDREGION(_b, _r) \
|
||||
do { \
|
||||
(_r)->base = (_b)->base; \
|
||||
(_r)->length = (_b)->used; \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_AVAILABLEREGION(_b, _r) \
|
||||
do { \
|
||||
(_r)->base = isc_buffer_used(_b); \
|
||||
(_r)->length = isc_buffer_availablelength(_b); \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_ADD(_b, _n) \
|
||||
do { \
|
||||
(_b)->used += (_n); \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_SUBTRACT(_b, _n) \
|
||||
do { \
|
||||
(_b)->used -= (_n); \
|
||||
if ((_b)->current > (_b)->used) \
|
||||
(_b)->current = (_b)->used; \
|
||||
if ((_b)->active > (_b)->used) \
|
||||
(_b)->active = (_b)->used; \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_CLEAR(_b) \
|
||||
do { \
|
||||
(_b)->used = 0; \
|
||||
(_b)->current = 0; \
|
||||
(_b)->active = 0; \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_CONSUMEDREGION(_b, _r) \
|
||||
do { \
|
||||
(_r)->base = (_b)->base; \
|
||||
(_r)->length = (_b)->current; \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_REMAININGREGION(_b, _r) \
|
||||
do { \
|
||||
(_r)->base = isc_buffer_current(_b); \
|
||||
(_r)->length = isc_buffer_remaininglength(_b); \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_ACTIVEREGION(_b, _r) \
|
||||
do { \
|
||||
if ((_b)->current < (_b)->active) { \
|
||||
(_r)->base = isc_buffer_current(_b); \
|
||||
(_r)->length = isc_buffer_activelength(_b); \
|
||||
} else { \
|
||||
(_r)->base = NULL; \
|
||||
(_r)->length = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_SETACTIVE(_b, _n) \
|
||||
do { \
|
||||
(_b)->active = (_b)->current + (_n); \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_FIRST(_b) \
|
||||
do { \
|
||||
(_b)->current = 0; \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_FORWARD(_b, _n) \
|
||||
do { \
|
||||
(_b)->current += (_n); \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_BACK(_b, _n) \
|
||||
do { \
|
||||
(_b)->current -= (_n); \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_PUTMEM(_b, _base, _length) \
|
||||
do { \
|
||||
memcpy(isc_buffer_used(_b), (_base), (_length)); \
|
||||
(_b)->used += (_length); \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_PUTSTR(_b, _source) \
|
||||
do { \
|
||||
unsigned int _length; \
|
||||
unsigned char *_cp; \
|
||||
_length = strlen(_source); \
|
||||
_cp = isc_buffer_used(_b); \
|
||||
memcpy(_cp, (_source), _length); \
|
||||
(_b)->used += (_length); \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_PUTUINT8(_b, _val) \
|
||||
do { \
|
||||
unsigned char *_cp; \
|
||||
isc_uint8_t _val2 = (_val); \
|
||||
_cp = isc_buffer_used(_b); \
|
||||
(_b)->used++; \
|
||||
_cp[0] = _val2 & 0x00ff; \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_PUTUINT16(_b, _val) \
|
||||
do { \
|
||||
unsigned char *_cp; \
|
||||
isc_uint16_t _val2 = (_val); \
|
||||
_cp = isc_buffer_used(_b); \
|
||||
(_b)->used += 2; \
|
||||
_cp[0] = (unsigned char)((_val2 & 0xff00U) >> 8); \
|
||||
_cp[1] = (unsigned char)(_val2 & 0x00ffU); \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_PUTUINT24(_b, _val) \
|
||||
do { \
|
||||
unsigned char *_cp; \
|
||||
isc_uint32_t _val2 = (_val); \
|
||||
_cp = isc_buffer_used(_b); \
|
||||
(_b)->used += 3; \
|
||||
_cp[0] = (unsigned char)((_val2 & 0xff0000U) >> 16); \
|
||||
_cp[1] = (unsigned char)((_val2 & 0xff00U) >> 8); \
|
||||
_cp[2] = (unsigned char)(_val2 & 0x00ffU); \
|
||||
} while (0)
|
||||
|
||||
#define ISC__BUFFER_PUTUINT32(_b, _val) \
|
||||
do { \
|
||||
unsigned char *_cp; \
|
||||
isc_uint32_t _val2 = (_val); \
|
||||
_cp = isc_buffer_used(_b); \
|
||||
(_b)->used += 4; \
|
||||
_cp[0] = (unsigned char)((_val2 & 0xff000000) >> 24); \
|
||||
_cp[1] = (unsigned char)((_val2 & 0x00ff0000) >> 16); \
|
||||
_cp[2] = (unsigned char)((_val2 & 0x0000ff00) >> 8); \
|
||||
_cp[3] = (unsigned char)((_val2 & 0x000000ff)); \
|
||||
} while (0)
|
||||
|
||||
#if defined(ISC_BUFFER_USEINLINE)
|
||||
#define isc_buffer_init ISC__BUFFER_INIT
|
||||
#define isc_buffer_initnull ISC__BUFFER_INITNULL
|
||||
#define isc_buffer_invalidate ISC__BUFFER_INVALIDATE
|
||||
#define isc_buffer_region ISC__BUFFER_REGION
|
||||
#define isc_buffer_usedregion ISC__BUFFER_USEDREGION
|
||||
#define isc_buffer_availableregion ISC__BUFFER_AVAILABLEREGION
|
||||
#define isc_buffer_add ISC__BUFFER_ADD
|
||||
#define isc_buffer_subtract ISC__BUFFER_SUBTRACT
|
||||
#define isc_buffer_clear ISC__BUFFER_CLEAR
|
||||
#define isc_buffer_consumedregion ISC__BUFFER_CONSUMEDREGION
|
||||
#define isc_buffer_remainingregion ISC__BUFFER_REMAININGREGION
|
||||
#define isc_buffer_activeregion ISC__BUFFER_ACTIVEREGION
|
||||
#define isc_buffer_setactive ISC__BUFFER_SETACTIVE
|
||||
#define isc_buffer_first ISC__BUFFER_FIRST
|
||||
#define isc_buffer_forward ISC__BUFFER_FORWARD
|
||||
#define isc_buffer_back ISC__BUFFER_BACK
|
||||
#define isc_buffer_putmem ISC__BUFFER_PUTMEM
|
||||
#define isc_buffer_putstr ISC__BUFFER_PUTSTR
|
||||
#define isc_buffer_putuint8 ISC__BUFFER_PUTUINT8
|
||||
#define isc_buffer_putuint16 ISC__BUFFER_PUTUINT16
|
||||
#define isc_buffer_putuint24 ISC__BUFFER_PUTUINT24
|
||||
#define isc_buffer_putuint32 ISC__BUFFER_PUTUINT32
|
||||
#else
|
||||
#define isc_buffer_init isc__buffer_init
|
||||
#define isc_buffer_initnull isc__buffer_initnull
|
||||
#define isc_buffer_invalidate isc__buffer_invalidate
|
||||
#define isc_buffer_region isc__buffer_region
|
||||
#define isc_buffer_usedregion isc__buffer_usedregion
|
||||
#define isc_buffer_availableregion isc__buffer_availableregion
|
||||
#define isc_buffer_add isc__buffer_add
|
||||
#define isc_buffer_subtract isc__buffer_subtract
|
||||
#define isc_buffer_clear isc__buffer_clear
|
||||
#define isc_buffer_consumedregion isc__buffer_consumedregion
|
||||
#define isc_buffer_remainingregion isc__buffer_remainingregion
|
||||
#define isc_buffer_activeregion isc__buffer_activeregion
|
||||
#define isc_buffer_setactive isc__buffer_setactive
|
||||
#define isc_buffer_first isc__buffer_first
|
||||
#define isc_buffer_forward isc__buffer_forward
|
||||
#define isc_buffer_back isc__buffer_back
|
||||
#define isc_buffer_putmem isc__buffer_putmem
|
||||
#define isc_buffer_putstr isc__buffer_putstr
|
||||
#define isc_buffer_putuint8 isc__buffer_putuint8
|
||||
#define isc_buffer_putuint16 isc__buffer_putuint16
|
||||
#define isc_buffer_putuint24 isc__buffer_putuint24
|
||||
#define isc_buffer_putuint32 isc__buffer_putuint32
|
||||
#endif
|
||||
|
||||
/*
|
||||
* No inline method for this one (yet).
|
||||
*/
|
||||
#define isc_buffer_putuint48 isc__buffer_putuint48
|
||||
|
||||
#endif /* ISC_BUFFER_H */
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: isc_error.h,v 1.1.10.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_ERROR_H
|
||||
#define ISC_ERROR_H 1
|
||||
|
||||
/*! \file isc/error.h */
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <isc/formatcheck.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
typedef void (*isc_errorcallback_t)(const char *, int, const char *, va_list);
|
||||
|
||||
/*% set unexpected error */
|
||||
void
|
||||
isc_error_setunexpected(isc_errorcallback_t);
|
||||
|
||||
/*% set fatal error */
|
||||
void
|
||||
isc_error_setfatal(isc_errorcallback_t);
|
||||
|
||||
/*% unexpected error */
|
||||
void
|
||||
isc_error_unexpected(const char *, int, const char *, ...)
|
||||
ISC_FORMAT_PRINTF(3, 4);
|
||||
|
||||
/*% fatal error */
|
||||
ISC_PLATFORM_NORETURN_PRE void
|
||||
isc_error_fatal(const char *, int, const char *, ...)
|
||||
ISC_FORMAT_PRINTF(3, 4) ISC_PLATFORM_NORETURN_POST;
|
||||
|
||||
/*% runtimecheck error */
|
||||
void
|
||||
isc_error_runtimecheck(const char *, int, const char *);
|
||||
|
||||
#define ISC_ERROR_RUNTIMECHECK(cond) \
|
||||
((void) ((cond) || \
|
||||
((isc_error_runtimecheck)(__FILE__, __LINE__, #cond), 0)))
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_ERROR_H */
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: isc_lib.h,v 1.1.10.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_LIB_H
|
||||
#define ISC_LIB_H 1
|
||||
|
||||
/*! \file isc/lib.h */
|
||||
|
||||
#include <isc/types.h>
|
||||
#include <isc/lang.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
LIBISC_EXTERNAL_DATA extern isc_msgcat_t *isc_msgcat;
|
||||
|
||||
void
|
||||
isc_lib_initmsgcat(void);
|
||||
/*!<
|
||||
* \brief Initialize the ISC library's message catalog, isc_msgcat, if it
|
||||
* has not already been initialized.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_lib_register(void);
|
||||
/*!<
|
||||
* \brief Register the ISC library implementations for some base services
|
||||
* such as memory or event management and handling socket or timer events.
|
||||
* An external application that wants to use the ISC library must call this
|
||||
* function very early in main().
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_LIB_H */
|
||||
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2006, 2007, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1997-2002 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: isc_list.h,v 1.1.10.2 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_LIST_H
|
||||
#define ISC_LIST_H 1
|
||||
#include <isc/boolean.h>
|
||||
#include <isc/assertions.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ISC_LIST_CHECKINIT
|
||||
#define ISC_LINK_INSIST(x) ISC_INSIST(x)
|
||||
#else
|
||||
#define ISC_LINK_INSIST(x)
|
||||
#endif
|
||||
|
||||
#define ISC_LIST(type) struct { type *head, *tail; }
|
||||
#define ISC_LIST_INIT(list) \
|
||||
do { (list).head = NULL; (list).tail = NULL; } while (0)
|
||||
|
||||
#define ISC_LINK(type) struct { type *prev, *next; }
|
||||
#define ISC_LINK_INIT_TYPE(elt, link, type) \
|
||||
do { \
|
||||
(elt)->link.prev = (type *)(-1); \
|
||||
(elt)->link.next = (type *)(-1); \
|
||||
} while (0)
|
||||
#define ISC_LINK_INIT(elt, link) \
|
||||
ISC_LINK_INIT_TYPE(elt, link, void)
|
||||
#define ISC_LINK_LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1))
|
||||
|
||||
#define ISC_LIST_HEAD(list) ((list).head)
|
||||
#define ISC_LIST_TAIL(list) ((list).tail)
|
||||
#define ISC_LIST_EMPTY(list) ISC_TF((list).head == NULL)
|
||||
|
||||
#define __ISC_LIST_PREPENDUNSAFE(list, elt, link) \
|
||||
do { \
|
||||
if ((list).head != NULL) \
|
||||
(list).head->link.prev = (elt); \
|
||||
else \
|
||||
(list).tail = (elt); \
|
||||
(elt)->link.prev = NULL; \
|
||||
(elt)->link.next = (list).head; \
|
||||
(list).head = (elt); \
|
||||
} while (0)
|
||||
|
||||
#define ISC_LIST_PREPEND(list, elt, link) \
|
||||
do { \
|
||||
ISC_LINK_INSIST(!ISC_LINK_LINKED(elt, link)); \
|
||||
__ISC_LIST_PREPENDUNSAFE(list, elt, link); \
|
||||
} while (0)
|
||||
|
||||
#define ISC_LIST_INITANDPREPEND(list, elt, link) \
|
||||
__ISC_LIST_PREPENDUNSAFE(list, elt, link)
|
||||
|
||||
#define __ISC_LIST_APPENDUNSAFE(list, elt, link) \
|
||||
do { \
|
||||
if ((list).tail != NULL) \
|
||||
(list).tail->link.next = (elt); \
|
||||
else \
|
||||
(list).head = (elt); \
|
||||
(elt)->link.prev = (list).tail; \
|
||||
(elt)->link.next = NULL; \
|
||||
(list).tail = (elt); \
|
||||
} while (0)
|
||||
|
||||
#define ISC_LIST_APPEND(list, elt, link) \
|
||||
do { \
|
||||
ISC_LINK_INSIST(!ISC_LINK_LINKED(elt, link)); \
|
||||
__ISC_LIST_APPENDUNSAFE(list, elt, link); \
|
||||
} while (0)
|
||||
|
||||
#define ISC_LIST_INITANDAPPEND(list, elt, link) \
|
||||
__ISC_LIST_APPENDUNSAFE(list, elt, link)
|
||||
|
||||
#define __ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, type) \
|
||||
do { \
|
||||
if ((elt)->link.next != NULL) \
|
||||
(elt)->link.next->link.prev = (elt)->link.prev; \
|
||||
else { \
|
||||
ISC_INSIST((list).tail == (elt)); \
|
||||
(list).tail = (elt)->link.prev; \
|
||||
} \
|
||||
if ((elt)->link.prev != NULL) \
|
||||
(elt)->link.prev->link.next = (elt)->link.next; \
|
||||
else { \
|
||||
ISC_INSIST((list).head == (elt)); \
|
||||
(list).head = (elt)->link.next; \
|
||||
} \
|
||||
(elt)->link.prev = (type *)(-1); \
|
||||
(elt)->link.next = (type *)(-1); \
|
||||
} while (0)
|
||||
|
||||
#define __ISC_LIST_UNLINKUNSAFE(list, elt, link) \
|
||||
__ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, void)
|
||||
|
||||
#define ISC_LIST_UNLINK_TYPE(list, elt, link, type) \
|
||||
do { \
|
||||
ISC_LINK_INSIST(ISC_LINK_LINKED(elt, link)); \
|
||||
__ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, type); \
|
||||
} while (0)
|
||||
#define ISC_LIST_UNLINK(list, elt, link) \
|
||||
ISC_LIST_UNLINK_TYPE(list, elt, link, void)
|
||||
|
||||
#define ISC_LIST_PREV(elt, link) ((elt)->link.prev)
|
||||
#define ISC_LIST_NEXT(elt, link) ((elt)->link.next)
|
||||
|
||||
#define __ISC_LIST_INSERTBEFOREUNSAFE(list, before, elt, link) \
|
||||
do { \
|
||||
if ((before)->link.prev == NULL) \
|
||||
ISC_LIST_PREPEND(list, elt, link); \
|
||||
else { \
|
||||
(elt)->link.prev = (before)->link.prev; \
|
||||
(before)->link.prev = (elt); \
|
||||
(elt)->link.prev->link.next = (elt); \
|
||||
(elt)->link.next = (before); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define ISC_LIST_INSERTBEFORE(list, before, elt, link) \
|
||||
do { \
|
||||
ISC_LINK_INSIST(ISC_LINK_LINKED(before, link)); \
|
||||
ISC_LINK_INSIST(!ISC_LINK_LINKED(elt, link)); \
|
||||
__ISC_LIST_INSERTBEFOREUNSAFE(list, before, elt, link); \
|
||||
} while (0)
|
||||
|
||||
#define __ISC_LIST_INSERTAFTERUNSAFE(list, after, elt, link) \
|
||||
do { \
|
||||
if ((after)->link.next == NULL) \
|
||||
ISC_LIST_APPEND(list, elt, link); \
|
||||
else { \
|
||||
(elt)->link.next = (after)->link.next; \
|
||||
(after)->link.next = (elt); \
|
||||
(elt)->link.next->link.prev = (elt); \
|
||||
(elt)->link.prev = (after); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define ISC_LIST_INSERTAFTER(list, after, elt, link) \
|
||||
do { \
|
||||
ISC_LINK_INSIST(ISC_LINK_LINKED(after, link)); \
|
||||
ISC_LINK_INSIST(!ISC_LINK_LINKED(elt, link)); \
|
||||
__ISC_LIST_INSERTAFTERUNSAFE(list, after, elt, link); \
|
||||
} while (0)
|
||||
|
||||
#define ISC_LIST_APPENDLIST(list1, list2, link) \
|
||||
do { \
|
||||
if (ISC_LIST_EMPTY(list1)) \
|
||||
(list1) = (list2); \
|
||||
else if (!ISC_LIST_EMPTY(list2)) { \
|
||||
(list1).tail->link.next = (list2).head; \
|
||||
(list2).head->link.prev = (list1).tail; \
|
||||
(list1).tail = (list2).tail; \
|
||||
} \
|
||||
(list2).head = NULL; \
|
||||
(list2).tail = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define ISC_LIST_PREPENDLIST(list1, list2, link) \
|
||||
do { \
|
||||
if (ISC_LIST_EMPTY(list1)) \
|
||||
(list1) = (list2); \
|
||||
else if (!ISC_LIST_EMPTY(list2)) { \
|
||||
(list2).tail->link.next = (list1).head; \
|
||||
(list1).head->link.prev = (list2).tail; \
|
||||
(list1).head = (list2).head; \
|
||||
} \
|
||||
(list2).head = NULL; \
|
||||
(list2).tail = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define ISC_LIST_ENQUEUE(list, elt, link) ISC_LIST_APPEND(list, elt, link)
|
||||
#define __ISC_LIST_ENQUEUEUNSAFE(list, elt, link) \
|
||||
__ISC_LIST_APPENDUNSAFE(list, elt, link)
|
||||
#define ISC_LIST_DEQUEUE(list, elt, link) \
|
||||
ISC_LIST_UNLINK_TYPE(list, elt, link, void)
|
||||
#define ISC_LIST_DEQUEUE_TYPE(list, elt, link, type) \
|
||||
ISC_LIST_UNLINK_TYPE(list, elt, link, type)
|
||||
#define __ISC_LIST_DEQUEUEUNSAFE(list, elt, link) \
|
||||
__ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, void)
|
||||
#define __ISC_LIST_DEQUEUEUNSAFE_TYPE(list, elt, link, type) \
|
||||
__ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, type)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* ISC_LIST_H */
|
||||
@@ -0,0 +1,756 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1997-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: isc_mem.h,v 1.1.10.2 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_MEM_H
|
||||
#define ISC_MEM_H 1
|
||||
|
||||
/*! \file isc/mem.h */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/types.h>
|
||||
#include <isc/xml.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
#define ISC_MEM_LOWATER 0
|
||||
#define ISC_MEM_HIWATER 1
|
||||
typedef void (*isc_mem_water_t)(void *, int);
|
||||
|
||||
typedef void * (*isc_memalloc_t)(void *, size_t);
|
||||
typedef void (*isc_memfree_t)(void *, void *);
|
||||
|
||||
/*%
|
||||
* Define ISC_MEM_DEBUG=1 to make all functions that free memory
|
||||
* set the pointer being freed to NULL after being freed.
|
||||
* This is the default; set ISC_MEM_DEBUG=0 to disable it.
|
||||
*/
|
||||
#ifndef ISC_MEM_DEBUG
|
||||
#define ISC_MEM_DEBUG 1
|
||||
#endif
|
||||
|
||||
/*%
|
||||
* Define ISC_MEM_TRACKLINES=1 to turn on detailed tracing of memory
|
||||
* allocation and freeing by file and line number.
|
||||
*/
|
||||
#ifndef ISC_MEM_TRACKLINES
|
||||
#define ISC_MEM_TRACKLINES 1
|
||||
#endif
|
||||
|
||||
/*%
|
||||
* Define ISC_MEM_CHECKOVERRUN=1 to turn on checks for using memory outside
|
||||
* the requested space. This will increase the size of each allocation.
|
||||
*/
|
||||
#ifndef ISC_MEM_CHECKOVERRUN
|
||||
#define ISC_MEM_CHECKOVERRUN 1
|
||||
#endif
|
||||
|
||||
/*%
|
||||
* Define ISC_MEM_FILL=1 to fill each block of memory returned to the system
|
||||
* with the byte string '0xbe'. This helps track down uninitialized pointers
|
||||
* and the like. On freeing memory, the space is filled with '0xde' for
|
||||
* the same reasons.
|
||||
*/
|
||||
#ifndef ISC_MEM_FILL
|
||||
#define ISC_MEM_FILL 1
|
||||
#endif
|
||||
|
||||
/*%
|
||||
* Define ISC_MEMPOOL_NAMES=1 to make memory pools store a symbolic
|
||||
* name so that the leaking pool can be more readily identified in
|
||||
* case of a memory leak.
|
||||
*/
|
||||
#ifndef ISC_MEMPOOL_NAMES
|
||||
#define ISC_MEMPOOL_NAMES 1
|
||||
#endif
|
||||
|
||||
LIBISC_EXTERNAL_DATA extern unsigned int isc_mem_debugging;
|
||||
/*@{*/
|
||||
#define ISC_MEM_DEBUGTRACE 0x00000001U
|
||||
#define ISC_MEM_DEBUGRECORD 0x00000002U
|
||||
#define ISC_MEM_DEBUGUSAGE 0x00000004U
|
||||
#define ISC_MEM_DEBUGSIZE 0x00000008U
|
||||
#define ISC_MEM_DEBUGCTX 0x00000010U
|
||||
#define ISC_MEM_DEBUGALL 0x0000001FU
|
||||
/*!<
|
||||
* The variable isc_mem_debugging holds a set of flags for
|
||||
* turning certain memory debugging options on or off at
|
||||
* runtime. It is initialized to the value ISC_MEM_DEGBUGGING,
|
||||
* which is 0 by default but may be overridden at compile time.
|
||||
* The following flags can be specified:
|
||||
*
|
||||
* \li #ISC_MEM_DEBUGTRACE
|
||||
* Log each allocation and free to isc_lctx.
|
||||
*
|
||||
* \li #ISC_MEM_DEBUGRECORD
|
||||
* Remember each allocation, and match them up on free.
|
||||
* Crash if a free doesn't match an allocation.
|
||||
*
|
||||
* \li #ISC_MEM_DEBUGUSAGE
|
||||
* If a hi_water mark is set, print the maximum inuse memory
|
||||
* every time it is raised once it exceeds the hi_water mark.
|
||||
*
|
||||
* \li #ISC_MEM_DEBUGSIZE
|
||||
* Check the size argument being passed to isc_mem_put() matches
|
||||
* that passed to isc_mem_get().
|
||||
*
|
||||
* \li #ISC_MEM_DEBUGCTX
|
||||
* Check the mctx argument being passed to isc_mem_put() matches
|
||||
* that passed to isc_mem_get().
|
||||
*/
|
||||
/*@}*/
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
#define _ISC_MEM_FILELINE , __FILE__, __LINE__
|
||||
#define _ISC_MEM_FLARG , const char *, unsigned int
|
||||
#else
|
||||
#define _ISC_MEM_FILELINE
|
||||
#define _ISC_MEM_FLARG
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Define ISC_MEM_USE_INTERNAL_MALLOC=1 to use the internal malloc()
|
||||
* implementation in preference to the system one. The internal malloc()
|
||||
* is very space-efficient, and quite fast on uniprocessor systems. It
|
||||
* performs poorly on multiprocessor machines.
|
||||
* JT: we can overcome the performance issue on multiprocessor machines
|
||||
* by carefully separating memory contexts.
|
||||
*/
|
||||
|
||||
#ifndef ISC_MEM_USE_INTERNAL_MALLOC
|
||||
#define ISC_MEM_USE_INTERNAL_MALLOC 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Flags for isc_mem_create2()calls.
|
||||
*/
|
||||
#define ISC_MEMFLAG_NOLOCK 0x00000001 /* no lock is necessary */
|
||||
#define ISC_MEMFLAG_INTERNAL 0x00000002 /* use internal malloc */
|
||||
#if ISC_MEM_USE_INTERNAL_MALLOC
|
||||
#define ISC_MEMFLAG_DEFAULT ISC_MEMFLAG_INTERNAL
|
||||
#else
|
||||
#define ISC_MEMFLAG_DEFAULT 0
|
||||
#endif
|
||||
|
||||
|
||||
/*%<
|
||||
* We use either isc___mem (three underscores) or isc__mem (two) depending on
|
||||
* whether it's for BIND9's internal purpose (with -DBIND9) or generic export
|
||||
* library. This condition is generally handled in isc/namespace.h, but for
|
||||
* Windows it doesn't work if it involves multiple times of macro expansion
|
||||
* (such as isc_mem to isc__mem then to isc___mem). The following definitions
|
||||
* are used to work around this portability issue. Right now, we don't support
|
||||
* the export library for Windows, so we always use the three-underscore
|
||||
* version.
|
||||
*/
|
||||
#ifdef WIN32
|
||||
#define ISCMEMFUNC(sfx) isc___mem_ ## sfx
|
||||
#define ISCMEMPOOLFUNC(sfx) isc___mempool_ ## sfx
|
||||
#else
|
||||
#define ISCMEMFUNC(sfx) isc__mem_ ## sfx
|
||||
#define ISCMEMPOOLFUNC(sfx) isc__mempool_ ## sfx
|
||||
#endif
|
||||
|
||||
#define isc_mem_get(c, s) ISCMEMFUNC(get)((c), (s) _ISC_MEM_FILELINE)
|
||||
#define isc_mem_allocate(c, s) ISCMEMFUNC(allocate)((c), (s) _ISC_MEM_FILELINE)
|
||||
#define isc_mem_reallocate(c, p, s) ISCMEMFUNC(reallocate)((c), (p), (s) _ISC_MEM_FILELINE)
|
||||
#define isc_mem_strdup(c, p) ISCMEMFUNC(strdup)((c), (p) _ISC_MEM_FILELINE)
|
||||
#define isc_mempool_get(c) ISCMEMPOOLFUNC(get)((c) _ISC_MEM_FILELINE)
|
||||
|
||||
/*%
|
||||
* isc_mem_putanddetach() is a convenience function for use where you
|
||||
* have a structure with an attached memory context.
|
||||
*
|
||||
* Given:
|
||||
*
|
||||
* \code
|
||||
* struct {
|
||||
* ...
|
||||
* isc_mem_t *mctx;
|
||||
* ...
|
||||
* } *ptr;
|
||||
*
|
||||
* isc_mem_t *mctx;
|
||||
*
|
||||
* isc_mem_putanddetach(&ptr->mctx, ptr, sizeof(*ptr));
|
||||
* \endcode
|
||||
*
|
||||
* is the equivalent of:
|
||||
*
|
||||
* \code
|
||||
* mctx = NULL;
|
||||
* isc_mem_attach(ptr->mctx, &mctx);
|
||||
* isc_mem_detach(&ptr->mctx);
|
||||
* isc_mem_put(mctx, ptr, sizeof(*ptr));
|
||||
* isc_mem_detach(&mctx);
|
||||
* \endcode
|
||||
*/
|
||||
|
||||
/*% memory and memory pool methods */
|
||||
typedef struct isc_memmethods {
|
||||
void (*attach)(isc_mem_t *source, isc_mem_t **targetp);
|
||||
void (*detach)(isc_mem_t **mctxp);
|
||||
void (*destroy)(isc_mem_t **mctxp);
|
||||
void *(*memget)(isc_mem_t *mctx, size_t size _ISC_MEM_FLARG);
|
||||
void (*memput)(isc_mem_t *mctx, void *ptr, size_t size _ISC_MEM_FLARG);
|
||||
void (*memputanddetach)(isc_mem_t **mctxp, void *ptr,
|
||||
size_t size _ISC_MEM_FLARG);
|
||||
void *(*memallocate)(isc_mem_t *mctx, size_t size _ISC_MEM_FLARG);
|
||||
void *(*memreallocate)(isc_mem_t *mctx, void *ptr,
|
||||
size_t size _ISC_MEM_FLARG);
|
||||
char *(*memstrdup)(isc_mem_t *mctx, const char *s _ISC_MEM_FLARG);
|
||||
void (*memfree)(isc_mem_t *mctx, void *ptr _ISC_MEM_FLARG);
|
||||
void (*setdestroycheck)(isc_mem_t *mctx, isc_boolean_t flag);
|
||||
void (*setwater)(isc_mem_t *ctx, isc_mem_water_t water,
|
||||
void *water_arg, size_t hiwater, size_t lowater);
|
||||
void (*waterack)(isc_mem_t *ctx, int flag);
|
||||
size_t (*inuse)(isc_mem_t *mctx);
|
||||
isc_boolean_t (*isovermem)(isc_mem_t *mctx);
|
||||
isc_result_t (*mpcreate)(isc_mem_t *mctx, size_t size,
|
||||
isc_mempool_t **mpctxp);
|
||||
} isc_memmethods_t;
|
||||
|
||||
typedef struct isc_mempoolmethods {
|
||||
void (*destroy)(isc_mempool_t **mpctxp);
|
||||
void *(*get)(isc_mempool_t *mpctx _ISC_MEM_FLARG);
|
||||
void (*put)(isc_mempool_t *mpctx, void *mem _ISC_MEM_FLARG);
|
||||
unsigned int (*getallocated)(isc_mempool_t *mpctx);
|
||||
void (*setmaxalloc)(isc_mempool_t *mpctx, unsigned int limit);
|
||||
void (*setfreemax)(isc_mempool_t *mpctx, unsigned int limit);
|
||||
void (*setname)(isc_mempool_t *mpctx, const char *name);
|
||||
void (*associatelock)(isc_mempool_t *mpctx, isc_mutex_t *lock);
|
||||
void (*setfillcount)(isc_mempool_t *mpctx, unsigned int limit);
|
||||
} isc_mempoolmethods_t;
|
||||
|
||||
/*%
|
||||
* This structure is actually just the common prefix of a memory context
|
||||
* implementation's version of an isc_mem_t.
|
||||
* \brief
|
||||
* Direct use of this structure by clients is forbidden. mctx implementations
|
||||
* may change the structure. 'magic' must be ISCAPI_MCTX_MAGIC for any of the
|
||||
* isc_mem_ routines to work. mctx implementations must maintain all mctx
|
||||
* invariants.
|
||||
*/
|
||||
struct isc_mem {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_memmethods_t *methods;
|
||||
};
|
||||
|
||||
#define ISCAPI_MCTX_MAGIC ISC_MAGIC('A','m','c','x')
|
||||
#define ISCAPI_MCTX_VALID(m) ((m) != NULL && \
|
||||
(m)->magic == ISCAPI_MCTX_MAGIC)
|
||||
|
||||
/*%
|
||||
* This is the common prefix of a memory pool context. The same note as
|
||||
* that for the mem structure applies.
|
||||
*/
|
||||
struct isc_mempool {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_mempoolmethods_t *methods;
|
||||
};
|
||||
|
||||
#define ISCAPI_MPOOL_MAGIC ISC_MAGIC('A','m','p','l')
|
||||
#define ISCAPI_MPOOL_VALID(mp) ((mp) != NULL && \
|
||||
(mp)->magic == ISCAPI_MPOOL_MAGIC)
|
||||
|
||||
#if ISC_MEM_DEBUG
|
||||
#define isc_mem_put(c, p, s) \
|
||||
do { \
|
||||
ISCMEMFUNC(put)((c), (p), (s) _ISC_MEM_FILELINE); \
|
||||
(p) = NULL; \
|
||||
} while (0)
|
||||
#define isc_mem_putanddetach(c, p, s) \
|
||||
do { \
|
||||
ISCMEMFUNC(putanddetach)((c), (p), (s) _ISC_MEM_FILELINE); \
|
||||
(p) = NULL; \
|
||||
} while (0)
|
||||
#define isc_mem_free(c, p) \
|
||||
do { \
|
||||
ISCMEMFUNC(free)((c), (p) _ISC_MEM_FILELINE); \
|
||||
(p) = NULL; \
|
||||
} while (0)
|
||||
#define isc_mempool_put(c, p) \
|
||||
do { \
|
||||
ISCMEMPOOLFUNC(put)((c), (p) _ISC_MEM_FILELINE); \
|
||||
(p) = NULL; \
|
||||
} while (0)
|
||||
#else
|
||||
#define isc_mem_put(c, p, s) ISCMEMFUNC(put)((c), (p), (s) _ISC_MEM_FILELINE)
|
||||
#define isc_mem_putanddetach(c, p, s) \
|
||||
ISCMEMFUNC(putanddetach)((c), (p), (s) _ISC_MEM_FILELINE)
|
||||
#define isc_mem_free(c, p) ISCMEMFUNC(free)((c), (p) _ISC_MEM_FILELINE)
|
||||
#define isc_mempool_put(c, p) ISCMEMPOOLFUNC(put)((c), (p) _ISC_MEM_FILELINE)
|
||||
#endif
|
||||
|
||||
/*@{*/
|
||||
isc_result_t
|
||||
isc_mem_create(size_t max_size, size_t target_size,
|
||||
isc_mem_t **mctxp);
|
||||
|
||||
isc_result_t
|
||||
isc_mem_create2(size_t max_size, size_t target_size,
|
||||
isc_mem_t **mctxp, unsigned int flags);
|
||||
|
||||
isc_result_t
|
||||
isc_mem_createx(size_t max_size, size_t target_size,
|
||||
isc_memalloc_t memalloc, isc_memfree_t memfree,
|
||||
void *arg, isc_mem_t **mctxp);
|
||||
|
||||
isc_result_t
|
||||
isc_mem_createx2(size_t max_size, size_t target_size,
|
||||
isc_memalloc_t memalloc, isc_memfree_t memfree,
|
||||
void *arg, isc_mem_t **mctxp, unsigned int flags);
|
||||
|
||||
/*!<
|
||||
* \brief Create a memory context.
|
||||
*
|
||||
* 'max_size' and 'target_size' are tuning parameters. When
|
||||
* ISC_MEMFLAG_INTERNAL is set, allocations smaller than 'max_size'
|
||||
* will be satisfied by getting blocks of size 'target_size' from the
|
||||
* system allocator and breaking them up into pieces; larger allocations
|
||||
* will use the system allocator directly. If 'max_size' and/or
|
||||
* 'target_size' are zero, default values will be * used. When
|
||||
* ISC_MEMFLAG_INTERNAL is not set, 'target_size' is ignored.
|
||||
*
|
||||
* 'max_size' is also used to size the statistics arrays and the array
|
||||
* used to record active memory when ISC_MEM_DEBUGRECORD is set. Setting
|
||||
* 'max_size' too low can have detrimental effects on performance.
|
||||
*
|
||||
* A memory context created using isc_mem_createx() will obtain
|
||||
* memory from the system by calling 'memalloc' and 'memfree',
|
||||
* passing them the argument 'arg'. A memory context created
|
||||
* using isc_mem_create() will use the standard library malloc()
|
||||
* and free().
|
||||
*
|
||||
* If ISC_MEMFLAG_NOLOCK is set in 'flags', the corresponding memory context
|
||||
* will be accessed without locking. The user who creates the context must
|
||||
* ensure there be no race. Since this can be a source of bug, it is generally
|
||||
* inadvisable to use this flag unless the user is very sure about the race
|
||||
* condition and the access to the object is highly performance sensitive.
|
||||
*
|
||||
* Requires:
|
||||
* mctxp != NULL && *mctxp == NULL */
|
||||
/*@}*/
|
||||
|
||||
/*@{*/
|
||||
void
|
||||
isc_mem_attach(isc_mem_t *, isc_mem_t **);
|
||||
void
|
||||
isc_mem_detach(isc_mem_t **);
|
||||
/*!<
|
||||
* \brief Attach to / detach from a memory context.
|
||||
*
|
||||
* This is intended for applications that use multiple memory contexts
|
||||
* in such a way that it is not obvious when the last allocations from
|
||||
* a given context has been freed and destroying the context is safe.
|
||||
*
|
||||
* Most applications do not need to call these functions as they can
|
||||
* simply create a single memory context at the beginning of main()
|
||||
* and destroy it at the end of main(), thereby guaranteeing that it
|
||||
* is not destroyed while there are outstanding allocations.
|
||||
*/
|
||||
/*@}*/
|
||||
|
||||
void
|
||||
isc_mem_destroy(isc_mem_t **);
|
||||
/*%<
|
||||
* Destroy a memory context.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_mem_ondestroy(isc_mem_t *ctx,
|
||||
isc_task_t *task,
|
||||
isc_event_t **event);
|
||||
/*%<
|
||||
* Request to be notified with an event when a memory context has
|
||||
* been successfully destroyed.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mem_stats(isc_mem_t *mctx, FILE *out);
|
||||
/*%<
|
||||
* Print memory usage statistics for 'mctx' on the stream 'out'.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mem_setdestroycheck(isc_mem_t *mctx,
|
||||
isc_boolean_t on);
|
||||
/*%<
|
||||
* If 'on' is ISC_TRUE, 'mctx' will check for memory leaks when
|
||||
* destroyed and abort the program if any are present.
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
void
|
||||
isc_mem_setquota(isc_mem_t *, size_t);
|
||||
size_t
|
||||
isc_mem_getquota(isc_mem_t *);
|
||||
/*%<
|
||||
* Set/get the memory quota of 'mctx'. This is a hard limit
|
||||
* on the amount of memory that may be allocated from mctx;
|
||||
* if it is exceeded, allocations will fail.
|
||||
*/
|
||||
/*@}*/
|
||||
|
||||
size_t
|
||||
isc_mem_inuse(isc_mem_t *mctx);
|
||||
/*%<
|
||||
* Get an estimate of the number of memory in use in 'mctx', in bytes.
|
||||
* This includes quantization overhead, but does not include memory
|
||||
* allocated from the system but not yet used.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_mem_isovermem(isc_mem_t *mctx);
|
||||
/*%<
|
||||
* Return true iff the memory context is in "over memory" state, i.e.,
|
||||
* a hiwater mark has been set and the used amount of memory has exceeds
|
||||
* the mark.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mem_setwater(isc_mem_t *mctx, isc_mem_water_t water, void *water_arg,
|
||||
size_t hiwater, size_t lowater);
|
||||
/*%<
|
||||
* Set high and low water marks for this memory context.
|
||||
*
|
||||
* When the memory usage of 'mctx' exceeds 'hiwater',
|
||||
* '(water)(water_arg, #ISC_MEM_HIWATER)' will be called. 'water' needs to
|
||||
* call isc_mem_waterack() with #ISC_MEM_HIWATER to acknowledge the state
|
||||
* change. 'water' may be called multiple times.
|
||||
*
|
||||
* When the usage drops below 'lowater', 'water' will again be called, this
|
||||
* time with #ISC_MEM_LOWATER. 'water' need to calls isc_mem_waterack() with
|
||||
* #ISC_MEM_LOWATER to acknowledge the change.
|
||||
*
|
||||
* static void
|
||||
* water(void *arg, int mark) {
|
||||
* struct foo *foo = arg;
|
||||
*
|
||||
* LOCK(&foo->marklock);
|
||||
* if (foo->mark != mark) {
|
||||
* foo->mark = mark;
|
||||
* ....
|
||||
* isc_mem_waterack(foo->mctx, mark);
|
||||
* }
|
||||
* UNLOCK(&foo->marklock);
|
||||
* }
|
||||
*
|
||||
* If 'water' is NULL then 'water_arg', 'hi_water' and 'lo_water' are
|
||||
* ignored and the state is reset.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
* 'water' is not NULL.
|
||||
* hi_water >= lo_water
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mem_waterack(isc_mem_t *ctx, int mark);
|
||||
/*%<
|
||||
* Called to acknowledge changes in signaled by calls to 'water'.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mem_printactive(isc_mem_t *mctx, FILE *file);
|
||||
/*%<
|
||||
* Print to 'file' all active memory in 'mctx'.
|
||||
*
|
||||
* Requires ISC_MEM_DEBUGRECORD to have been set.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mem_printallactive(FILE *file);
|
||||
/*%<
|
||||
* Print to 'file' all active memory in all contexts.
|
||||
*
|
||||
* Requires ISC_MEM_DEBUGRECORD to have been set.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mem_checkdestroyed(FILE *file);
|
||||
/*%<
|
||||
* Check that all memory contexts have been destroyed.
|
||||
* Prints out those that have not been.
|
||||
* Fatally fails if there are still active contexts.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_mem_references(isc_mem_t *ctx);
|
||||
/*%<
|
||||
* Return the current reference count.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mem_setname(isc_mem_t *ctx, const char *name, void *tag);
|
||||
/*%<
|
||||
* Name 'ctx'.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li Only the first 15 characters of 'name' will be copied.
|
||||
*
|
||||
*\li 'tag' is for debugging purposes only.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'ctx' is a valid ctx.
|
||||
*/
|
||||
|
||||
const char *
|
||||
isc_mem_getname(isc_mem_t *ctx);
|
||||
/*%<
|
||||
* Get the name of 'ctx', as previously set using isc_mem_setname().
|
||||
*
|
||||
* Requires:
|
||||
*\li 'ctx' is a valid ctx.
|
||||
*
|
||||
* Returns:
|
||||
*\li A non-NULL pointer to a null-terminated string.
|
||||
* If the ctx has not been named, the string is
|
||||
* empty.
|
||||
*/
|
||||
|
||||
void *
|
||||
isc_mem_gettag(isc_mem_t *ctx);
|
||||
/*%<
|
||||
* Get the tag value for 'task', as previously set using isc_mem_setname().
|
||||
*
|
||||
* Requires:
|
||||
*\li 'ctx' is a valid ctx.
|
||||
*
|
||||
* Notes:
|
||||
*\li This function is for debugging purposes only.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'ctx' is a valid task.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_LIBXML2
|
||||
void
|
||||
isc_mem_renderxml(xmlTextWriterPtr writer);
|
||||
/*%<
|
||||
* Render all contexts' statistics and status in XML for writer.
|
||||
*/
|
||||
#endif /* HAVE_LIBXML2 */
|
||||
|
||||
/*
|
||||
* Memory pools
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp);
|
||||
/*%<
|
||||
* Create a memory pool.
|
||||
*
|
||||
* Requires:
|
||||
*\li mctx is a valid memory context.
|
||||
*\li size > 0
|
||||
*\li mpctxp != NULL and *mpctxp == NULL
|
||||
*
|
||||
* Defaults:
|
||||
*\li maxalloc = UINT_MAX
|
||||
*\li freemax = 1
|
||||
*\li fillcount = 1
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_NOMEMORY -- not enough memory to create pool
|
||||
*\li #ISC_R_SUCCESS -- all is well.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mempool_destroy(isc_mempool_t **mpctxp);
|
||||
/*%<
|
||||
* Destroy a memory pool.
|
||||
*
|
||||
* Requires:
|
||||
*\li mpctxp != NULL && *mpctxp is a valid pool.
|
||||
*\li The pool has no un"put" allocations outstanding
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mempool_setname(isc_mempool_t *mpctx, const char *name);
|
||||
/*%<
|
||||
* Associate a name with a memory pool. At most 15 characters may be used.
|
||||
*
|
||||
* Requires:
|
||||
*\li mpctx is a valid pool.
|
||||
*\li name != NULL;
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mempool_associatelock(isc_mempool_t *mpctx, isc_mutex_t *lock);
|
||||
/*%<
|
||||
* Associate a lock with this memory pool.
|
||||
*
|
||||
* This lock is used when getting or putting items using this memory pool,
|
||||
* and it is also used to set or get internal state via the isc_mempool_get*()
|
||||
* and isc_mempool_set*() set of functions.
|
||||
*
|
||||
* Multiple pools can each share a single lock. For instance, if "manager"
|
||||
* type object contained pools for various sizes of events, and each of
|
||||
* these pools used a common lock. Note that this lock must NEVER be used
|
||||
* by other than mempool routines once it is given to a pool, since that can
|
||||
* easily cause double locking.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li mpctpx is a valid pool.
|
||||
*
|
||||
*\li lock != NULL.
|
||||
*
|
||||
*\li No previous lock is assigned to this pool.
|
||||
*
|
||||
*\li The lock is initialized before calling this function via the normal
|
||||
* means of doing that.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following functions get/set various parameters. Note that due to
|
||||
* the unlocked nature of pools these are potentially random values unless
|
||||
* the imposed externally provided locking protocols are followed.
|
||||
*
|
||||
* Also note that the quota limits will not always take immediate effect.
|
||||
* For instance, setting "maxalloc" to a number smaller than the currently
|
||||
* allocated count is permitted. New allocations will be refused until
|
||||
* the count drops below this threshold.
|
||||
*
|
||||
* All functions require (in addition to other requirements):
|
||||
* mpctx is a valid memory pool
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getfreemax(isc_mempool_t *mpctx);
|
||||
/*%<
|
||||
* Returns the maximum allowed size of the free list.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mempool_setfreemax(isc_mempool_t *mpctx, unsigned int limit);
|
||||
/*%<
|
||||
* Sets the maximum allowed size of the free list.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getfreecount(isc_mempool_t *mpctx);
|
||||
/*%<
|
||||
* Returns current size of the free list.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getmaxalloc(isc_mempool_t *mpctx);
|
||||
/*!<
|
||||
* Returns the maximum allowed number of allocations.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mempool_setmaxalloc(isc_mempool_t *mpctx, unsigned int limit);
|
||||
/*%<
|
||||
* Sets the maximum allowed number of allocations.
|
||||
*
|
||||
* Additional requirements:
|
||||
*\li limit > 0
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getallocated(isc_mempool_t *mpctx);
|
||||
/*%<
|
||||
* Returns the number of items allocated from this pool.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_mempool_getfillcount(isc_mempool_t *mpctx);
|
||||
/*%<
|
||||
* Returns the number of items allocated as a block from the parent memory
|
||||
* context when the free list is empty.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mempool_setfillcount(isc_mempool_t *mpctx, unsigned int limit);
|
||||
/*%<
|
||||
* Sets the fillcount.
|
||||
*
|
||||
* Additional requirements:
|
||||
*\li limit > 0
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Pseudo-private functions for use via macros. Do not call directly.
|
||||
*/
|
||||
void *
|
||||
ISCMEMFUNC(get)(isc_mem_t *, size_t _ISC_MEM_FLARG);
|
||||
void
|
||||
ISCMEMFUNC(putanddetach)(isc_mem_t **, void *, size_t _ISC_MEM_FLARG);
|
||||
void
|
||||
ISCMEMFUNC(put)(isc_mem_t *, void *, size_t _ISC_MEM_FLARG);
|
||||
void *
|
||||
ISCMEMFUNC(allocate)(isc_mem_t *, size_t _ISC_MEM_FLARG);
|
||||
void *
|
||||
ISCMEMFUNC(reallocate)(isc_mem_t *, void *, size_t _ISC_MEM_FLARG);
|
||||
void
|
||||
ISCMEMFUNC(free)(isc_mem_t *, void * _ISC_MEM_FLARG);
|
||||
char *
|
||||
ISCMEMFUNC(strdup)(isc_mem_t *, const char *_ISC_MEM_FLARG);
|
||||
void *
|
||||
ISCMEMPOOLFUNC(get)(isc_mempool_t * _ISC_MEM_FLARG);
|
||||
void
|
||||
ISCMEMPOOLFUNC(put)(isc_mempool_t *, void * _ISC_MEM_FLARG);
|
||||
|
||||
#ifdef USE_MEMIMPREGISTER
|
||||
|
||||
/*%<
|
||||
* See isc_mem_create2() above.
|
||||
*/
|
||||
typedef isc_result_t
|
||||
(*isc_memcreatefunc_t)(size_t init_max_size, size_t target_size,
|
||||
isc_mem_t **ctxp, unsigned int flags);
|
||||
|
||||
isc_result_t
|
||||
isc_mem_register(isc_memcreatefunc_t createfunc);
|
||||
/*%<
|
||||
* Register a new memory management implementation and add it to the list of
|
||||
* supported implementations. This function must be called when a different
|
||||
* memory management library is used than the one contained in the ISC library.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc__mem_register(void);
|
||||
/*%<
|
||||
* A short cut function that specifies the memory management module in the ISC
|
||||
* library for isc_mem_register(). An application that uses the ISC library
|
||||
* usually do not have to care about this function: it would call
|
||||
* isc_lib_register(), which internally calls this function.
|
||||
*/
|
||||
#endif /* USE_MEMIMPREGISTER */
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ISC_MEM_H */
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2007, 2008 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: isc_strerror.h,v 1.1.10.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_STRERROR_H
|
||||
#define ISC_STRERROR_H
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*% String Error Size */
|
||||
#define ISC_STRERRORSIZE 128
|
||||
|
||||
/*%
|
||||
* Provide a thread safe wrapper to strerror().
|
||||
*
|
||||
* Requires:
|
||||
* 'buf' to be non NULL.
|
||||
*/
|
||||
void
|
||||
isc__strerror(int num, char *buf, size_t bufsize);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_STRERROR_H */
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: iterated_hash.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_ITERATED_HASH_H
|
||||
#define ISC_ITERATED_HASH_H 1
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/sha1.h>
|
||||
|
||||
/*
|
||||
* The maximal hash length that can be encoded it a name
|
||||
* using base32hex. floor(255/8)*5
|
||||
*/
|
||||
#define NSEC3_MAX_HASH_LENGTH 155
|
||||
|
||||
/*
|
||||
* The maximum has that can be encoded in a single label using
|
||||
* base32hex. floor(63/8)*5
|
||||
*/
|
||||
#define NSEC3_MAX_LABEL_HASH 35
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
int isc_iterated_hash(unsigned char out[NSEC3_MAX_HASH_LENGTH],
|
||||
unsigned int hashalg, int iterations,
|
||||
const unsigned char *salt, int saltlength,
|
||||
const unsigned char *in, int inlength);
|
||||
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_ITERATED_HASH_H */
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: lang.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_LANG_H
|
||||
#define ISC_LANG_H 1
|
||||
|
||||
/*! \file isc/lang.h */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define ISC_LANG_BEGINDECLS extern "C" {
|
||||
#define ISC_LANG_ENDDECLS }
|
||||
#else
|
||||
#define ISC_LANG_BEGINDECLS
|
||||
#define ISC_LANG_ENDDECLS
|
||||
#endif
|
||||
|
||||
#endif /* ISC_LANG_H */
|
||||
@@ -0,0 +1,431 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2007, 2008 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2002 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: lex.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_LEX_H
|
||||
#define ISC_LEX_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/lex.h
|
||||
* \brief The "lex" module provides a lightweight tokenizer. It can operate
|
||||
* on files or buffers, and can handle "include". It is designed for
|
||||
* parsing of DNS master files and the BIND configuration file, but
|
||||
* should be general enough to tokenize other things, e.g. HTTP.
|
||||
*
|
||||
* \li MP:
|
||||
* No synchronization is provided. Clients must ensure exclusive
|
||||
* access.
|
||||
*
|
||||
* \li Reliability:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Resources:
|
||||
* TBS
|
||||
*
|
||||
* \li Security:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Standards:
|
||||
* None.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports
|
||||
***/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/region.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/***
|
||||
*** Options
|
||||
***/
|
||||
|
||||
/*@{*/
|
||||
/*!
|
||||
* Various options for isc_lex_gettoken().
|
||||
*/
|
||||
|
||||
#define ISC_LEXOPT_EOL 0x01 /*%< Want end-of-line token. */
|
||||
#define ISC_LEXOPT_EOF 0x02 /*%< Want end-of-file token. */
|
||||
#define ISC_LEXOPT_INITIALWS 0x04 /*%< Want initial whitespace. */
|
||||
#define ISC_LEXOPT_NUMBER 0x08 /*%< Recognize numbers. */
|
||||
#define ISC_LEXOPT_QSTRING 0x10 /*%< Recognize qstrings. */
|
||||
/*@}*/
|
||||
|
||||
/*@{*/
|
||||
/*!
|
||||
* The ISC_LEXOPT_DNSMULTILINE option handles the processing of '(' and ')' in
|
||||
* the DNS master file format. If this option is set, then the
|
||||
* ISC_LEXOPT_INITIALWS and ISC_LEXOPT_EOL options will be ignored when
|
||||
* the paren count is > 0. To use this option, '(' and ')' must be special
|
||||
* characters.
|
||||
*/
|
||||
#define ISC_LEXOPT_DNSMULTILINE 0x20 /*%< Handle '(' and ')'. */
|
||||
#define ISC_LEXOPT_NOMORE 0x40 /*%< Want "no more" token. */
|
||||
|
||||
#define ISC_LEXOPT_CNUMBER 0x80 /*%< Recognize octal and hex. */
|
||||
#define ISC_LEXOPT_ESCAPE 0x100 /*%< Recognize escapes. */
|
||||
#define ISC_LEXOPT_QSTRINGMULTILINE 0x200 /*%< Allow multiline "" strings */
|
||||
#define ISC_LEXOPT_OCTAL 0x400 /*%< Expect a octal number. */
|
||||
/*@}*/
|
||||
/*@{*/
|
||||
/*!
|
||||
* Various commenting styles, which may be changed at any time with
|
||||
* isc_lex_setcomments().
|
||||
*/
|
||||
|
||||
#define ISC_LEXCOMMENT_C 0x01
|
||||
#define ISC_LEXCOMMENT_CPLUSPLUS 0x02
|
||||
#define ISC_LEXCOMMENT_SHELL 0x04
|
||||
#define ISC_LEXCOMMENT_DNSMASTERFILE 0x08
|
||||
/*@}*/
|
||||
|
||||
/***
|
||||
*** Types
|
||||
***/
|
||||
|
||||
/*! Lex */
|
||||
|
||||
typedef char isc_lexspecials_t[256];
|
||||
|
||||
/* Tokens */
|
||||
|
||||
typedef enum {
|
||||
isc_tokentype_unknown = 0,
|
||||
isc_tokentype_string = 1,
|
||||
isc_tokentype_number = 2,
|
||||
isc_tokentype_qstring = 3,
|
||||
isc_tokentype_eol = 4,
|
||||
isc_tokentype_eof = 5,
|
||||
isc_tokentype_initialws = 6,
|
||||
isc_tokentype_special = 7,
|
||||
isc_tokentype_nomore = 8
|
||||
} isc_tokentype_t;
|
||||
|
||||
typedef union {
|
||||
char as_char;
|
||||
unsigned long as_ulong;
|
||||
isc_region_t as_region;
|
||||
isc_textregion_t as_textregion;
|
||||
void * as_pointer;
|
||||
} isc_tokenvalue_t;
|
||||
|
||||
typedef struct isc_token {
|
||||
isc_tokentype_t type;
|
||||
isc_tokenvalue_t value;
|
||||
} isc_token_t;
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
isc_result_t
|
||||
isc_lex_create(isc_mem_t *mctx, size_t max_token, isc_lex_t **lexp);
|
||||
/*%<
|
||||
* Create a lexer.
|
||||
*
|
||||
* 'max_token' is a hint of the number of bytes in the largest token.
|
||||
*
|
||||
* Requires:
|
||||
*\li '*lexp' is a valid lexer.
|
||||
*
|
||||
*\li max_token > 0.
|
||||
*
|
||||
* Ensures:
|
||||
*\li On success, *lexp is attached to the newly created lexer.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_NOMEMORY
|
||||
*/
|
||||
|
||||
void
|
||||
isc_lex_destroy(isc_lex_t **lexp);
|
||||
/*%<
|
||||
* Destroy the lexer.
|
||||
*
|
||||
* Requires:
|
||||
*\li '*lexp' is a valid lexer.
|
||||
*
|
||||
* Ensures:
|
||||
*\li *lexp == NULL
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_lex_getcomments(isc_lex_t *lex);
|
||||
/*%<
|
||||
* Return the current lexer commenting styles.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*
|
||||
* Returns:
|
||||
*\li The commenting sytles which are currently allowed.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_lex_setcomments(isc_lex_t *lex, unsigned int comments);
|
||||
/*%<
|
||||
* Set allowed lexer commenting styles.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*
|
||||
*\li 'comments' has meaningful values.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_lex_getspecials(isc_lex_t *lex, isc_lexspecials_t specials);
|
||||
/*%<
|
||||
* Put the current list of specials into 'specials'.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_lex_setspecials(isc_lex_t *lex, isc_lexspecials_t specials);
|
||||
/*!<
|
||||
* The characters in 'specials' are returned as tokens. Along with
|
||||
* whitespace, they delimit strings and numbers.
|
||||
*
|
||||
* Note:
|
||||
*\li Comment processing takes precedence over special character
|
||||
* recognition.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_lex_openfile(isc_lex_t *lex, const char *filename);
|
||||
/*%<
|
||||
* Open 'filename' and make it the current input source for 'lex'.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*
|
||||
*\li filename is a valid C string.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_NOMEMORY Out of memory
|
||||
*\li #ISC_R_NOTFOUND File not found
|
||||
*\li #ISC_R_NOPERM No permission to open file
|
||||
*\li #ISC_R_FAILURE Couldn't open file, not sure why
|
||||
*\li #ISC_R_UNEXPECTED
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_lex_openstream(isc_lex_t *lex, FILE *stream);
|
||||
/*%<
|
||||
* Make 'stream' the current input source for 'lex'.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*
|
||||
*\li 'stream' is a valid C stream.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_NOMEMORY Out of memory
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_lex_openbuffer(isc_lex_t *lex, isc_buffer_t *buffer);
|
||||
/*%<
|
||||
* Make 'buffer' the current input source for 'lex'.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*
|
||||
*\li 'buffer' is a valid buffer.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_NOMEMORY Out of memory
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_lex_close(isc_lex_t *lex);
|
||||
/*%<
|
||||
* Close the most recently opened object (i.e. file or buffer).
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_NOMORE No more input sources
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp);
|
||||
/*%<
|
||||
* Get the next token.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*
|
||||
*\li 'lex' has an input source.
|
||||
*
|
||||
*\li 'options' contains valid options.
|
||||
*
|
||||
*\li '*tokenp' is a valid pointer.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_UNEXPECTEDEND
|
||||
*\li #ISC_R_NOMEMORY
|
||||
*
|
||||
* These two results are returned only if their corresponding lexer
|
||||
* options are not set.
|
||||
*
|
||||
*\li #ISC_R_EOF End of input source
|
||||
*\li #ISC_R_NOMORE No more input sources
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_lex_getmastertoken(isc_lex_t *lex, isc_token_t *token,
|
||||
isc_tokentype_t expect, isc_boolean_t eol);
|
||||
/*%<
|
||||
* Get the next token from a DNS master file type stream. This is a
|
||||
* convenience function that sets appropriate options and handles quoted
|
||||
* strings and end of line correctly for master files. It also ungets
|
||||
* unexpected tokens.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*
|
||||
*\li 'token' is a valid pointer
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* \li any return code from isc_lex_gettoken().
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_lex_getoctaltoken(isc_lex_t *lex, isc_token_t *token, isc_boolean_t eol);
|
||||
/*%<
|
||||
* Get the next token from a DNS master file type stream. This is a
|
||||
* convenience function that sets appropriate options and handles end
|
||||
* of line correctly for master files. It also ungets unexpected tokens.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*
|
||||
*\li 'token' is a valid pointer
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* \li any return code from isc_lex_gettoken().
|
||||
*/
|
||||
|
||||
void
|
||||
isc_lex_ungettoken(isc_lex_t *lex, isc_token_t *tokenp);
|
||||
/*%<
|
||||
* Unget the current token.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*
|
||||
*\li 'lex' has an input source.
|
||||
*
|
||||
*\li 'tokenp' points to a valid token.
|
||||
*
|
||||
*\li There is no ungotten token already.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_lex_getlasttokentext(isc_lex_t *lex, isc_token_t *tokenp, isc_region_t *r);
|
||||
/*%<
|
||||
* Returns a region containing the text of the last token returned.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*
|
||||
*\li 'lex' has an input source.
|
||||
*
|
||||
*\li 'tokenp' points to a valid token.
|
||||
*
|
||||
*\li A token has been gotten and not ungotten.
|
||||
*/
|
||||
|
||||
char *
|
||||
isc_lex_getsourcename(isc_lex_t *lex);
|
||||
/*%<
|
||||
* Return the input source name.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*
|
||||
* Returns:
|
||||
* \li source name or NULL if no current source.
|
||||
*\li result valid while current input source exists.
|
||||
*/
|
||||
|
||||
|
||||
unsigned long
|
||||
isc_lex_getsourceline(isc_lex_t *lex);
|
||||
/*%<
|
||||
* Return the input source line number.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*
|
||||
* Returns:
|
||||
*\li Current line number or 0 if no current source.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_lex_setsourcename(isc_lex_t *lex, const char *name);
|
||||
/*%<
|
||||
* Assigns a new name to the input source.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
* \li 'lex' is a valid lexer.
|
||||
*
|
||||
* Returns:
|
||||
* \li #ISC_R_SUCCESS
|
||||
* \li #ISC_R_NOMEMORY
|
||||
* \li #ISC_R_NOTFOUND - there are no sources.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_lex_isfile(isc_lex_t *lex);
|
||||
/*%<
|
||||
* Return whether the current input source is a file.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'lex' is a valid lexer.
|
||||
*
|
||||
* Returns:
|
||||
* \li #ISC_TRUE if the current input is a file,
|
||||
*\li #ISC_FALSE otherwise.
|
||||
*/
|
||||
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_LEX_H */
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: lfsr.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_LFSR_H
|
||||
#define ISC_LFSR_H 1
|
||||
|
||||
/*! \file isc/lfsr.h */
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
typedef struct isc_lfsr isc_lfsr_t;
|
||||
|
||||
/*%
|
||||
* This function is called when reseeding is needed. It is allowed to
|
||||
* modify any state in the LFSR in any way it sees fit OTHER THAN "bits".
|
||||
*
|
||||
* It MUST set "count" to a new value or the lfsr will never reseed again.
|
||||
*
|
||||
* Also, a reseed will never occur in the middle of an extraction. This
|
||||
* is purely an optimization, and is probably what one would want.
|
||||
*/
|
||||
typedef void (*isc_lfsrreseed_t)(isc_lfsr_t *, void *);
|
||||
|
||||
/*%
|
||||
* The members of this structure can be used by the application, but care
|
||||
* needs to be taken to not change state once the lfsr is in operation.
|
||||
*/
|
||||
struct isc_lfsr {
|
||||
isc_uint32_t state; /*%< previous state */
|
||||
unsigned int bits; /*%< length */
|
||||
isc_uint32_t tap; /*%< bit taps */
|
||||
unsigned int count; /*%< reseed count (in BITS!) */
|
||||
isc_lfsrreseed_t reseed; /*%< reseed function */
|
||||
void *arg; /*%< reseed function argument */
|
||||
};
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
|
||||
void
|
||||
isc_lfsr_init(isc_lfsr_t *lfsr, isc_uint32_t state, unsigned int bits,
|
||||
isc_uint32_t tap, unsigned int count,
|
||||
isc_lfsrreseed_t reseed, void *arg);
|
||||
/*%<
|
||||
* Initialize an LFSR.
|
||||
*
|
||||
* Note:
|
||||
*
|
||||
*\li Putting untrusted values into this function will cause the LFSR to
|
||||
* generate (perhaps) non-maximal length sequences.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li lfsr != NULL
|
||||
*
|
||||
*\li 8 <= bits <= 32
|
||||
*
|
||||
*\li tap != 0
|
||||
*/
|
||||
|
||||
void
|
||||
isc_lfsr_generate(isc_lfsr_t *lfsr, void *data, unsigned int count);
|
||||
/*%<
|
||||
* Returns "count" bytes of data from the LFSR.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li lfsr be valid.
|
||||
*
|
||||
*\li data != NULL.
|
||||
*
|
||||
*\li count > 0.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_lfsr_skip(isc_lfsr_t *lfsr, unsigned int skip);
|
||||
/*%<
|
||||
* Skip "skip" states.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li lfsr be valid.
|
||||
*/
|
||||
|
||||
isc_uint32_t
|
||||
isc_lfsr_generate32(isc_lfsr_t *lfsr1, isc_lfsr_t *lfsr2);
|
||||
/*%<
|
||||
* Given two LFSRs, use the current state from each to skip entries in the
|
||||
* other. The next states are then xor'd together and returned.
|
||||
*
|
||||
* WARNING:
|
||||
*
|
||||
*\li This function is used only for very, very low security data, such
|
||||
* as DNS message IDs where it is desired to have an unpredictable
|
||||
* stream of bytes that are harder to predict than a simple flooding
|
||||
* attack.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li Since the current state from each of the LFSRs is used to skip
|
||||
* state in the other, it is important that no state be leaked
|
||||
* from either LFSR.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li lfsr1 and lfsr2 be valid.
|
||||
*
|
||||
*\li 1 <= skipbits <= 31
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_LFSR_H */
|
||||
@@ -0,0 +1,914 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2002 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: log.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_LOG_H
|
||||
#define ISC_LOG_H 1
|
||||
|
||||
/*! \file isc/log.h */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <syslog.h> /* XXXDCL NT */
|
||||
|
||||
#include <isc/formatcheck.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/*@{*/
|
||||
/*!
|
||||
* \brief Severity levels, patterned after Unix's syslog levels.
|
||||
*
|
||||
*/
|
||||
#define ISC_LOG_DEBUG(level) (level)
|
||||
/*!
|
||||
* #ISC_LOG_DYNAMIC can only be used for defining channels with
|
||||
* isc_log_createchannel(), not to specify a level in isc_log_write().
|
||||
*/
|
||||
#define ISC_LOG_DYNAMIC 0
|
||||
#define ISC_LOG_INFO (-1)
|
||||
#define ISC_LOG_NOTICE (-2)
|
||||
#define ISC_LOG_WARNING (-3)
|
||||
#define ISC_LOG_ERROR (-4)
|
||||
#define ISC_LOG_CRITICAL (-5)
|
||||
/*@}*/
|
||||
|
||||
/*@{*/
|
||||
/*!
|
||||
* \brief Destinations.
|
||||
*/
|
||||
#define ISC_LOG_TONULL 1
|
||||
#define ISC_LOG_TOSYSLOG 2
|
||||
#define ISC_LOG_TOFILE 3
|
||||
#define ISC_LOG_TOFILEDESC 4
|
||||
/*@}*/
|
||||
|
||||
/*@{*/
|
||||
/*%
|
||||
* Channel flags.
|
||||
*/
|
||||
#define ISC_LOG_PRINTTIME 0x0001
|
||||
#define ISC_LOG_PRINTLEVEL 0x0002
|
||||
#define ISC_LOG_PRINTCATEGORY 0x0004
|
||||
#define ISC_LOG_PRINTMODULE 0x0008
|
||||
#define ISC_LOG_PRINTTAG 0x0010
|
||||
#define ISC_LOG_PRINTALL 0x001F
|
||||
#define ISC_LOG_DEBUGONLY 0x1000
|
||||
#define ISC_LOG_OPENERR 0x8000 /* internal */
|
||||
/*@}*/
|
||||
|
||||
/*@{*/
|
||||
/*!
|
||||
* \brief Other options.
|
||||
*
|
||||
* XXXDCL INFINITE doesn't yet work. Arguably it isn't needed, but
|
||||
* since I am intend to make large number of versions work efficiently,
|
||||
* INFINITE is going to be trivial to add to that.
|
||||
*/
|
||||
#define ISC_LOG_ROLLINFINITE (-1)
|
||||
#define ISC_LOG_ROLLNEVER (-2)
|
||||
/*@}*/
|
||||
|
||||
/*!
|
||||
* \brief Used to name the categories used by a library.
|
||||
*
|
||||
* An array of isc_logcategory
|
||||
* structures names each category, and the id value is initialized by calling
|
||||
* isc_log_registercategories.
|
||||
*/
|
||||
struct isc_logcategory {
|
||||
const char *name;
|
||||
unsigned int id;
|
||||
};
|
||||
|
||||
/*%
|
||||
* Similar to isc_logcategory, but for all the modules a library defines.
|
||||
*/
|
||||
struct isc_logmodule {
|
||||
const char *name;
|
||||
unsigned int id;
|
||||
};
|
||||
|
||||
/*%
|
||||
* The isc_logfile structure is initialized as part of an isc_logdestination
|
||||
* before calling isc_log_createchannel().
|
||||
*
|
||||
* When defining an #ISC_LOG_TOFILE
|
||||
* channel the name, versions and maximum_size should be set before calling
|
||||
* isc_log_createchannel(). To define an #ISC_LOG_TOFILEDESC channel set only
|
||||
* the stream before the call.
|
||||
*
|
||||
* Setting maximum_size to zero implies no maximum.
|
||||
*/
|
||||
typedef struct isc_logfile {
|
||||
FILE *stream; /*%< Initialized to NULL for #ISC_LOG_TOFILE. */
|
||||
const char *name; /*%< NULL for #ISC_LOG_TOFILEDESC. */
|
||||
int versions; /* >= 0, #ISC_LOG_ROLLNEVER, #ISC_LOG_ROLLINFINITE. */
|
||||
/*%
|
||||
* stdio's ftell is standardized to return a long, which may well not
|
||||
* be big enough for the largest file supportable by the operating
|
||||
* system (though it is _probably_ big enough for the largest log
|
||||
* anyone would want). st_size returned by fstat should be typedef'd
|
||||
* to a size large enough for the largest possible file on a system.
|
||||
*/
|
||||
isc_offset_t maximum_size;
|
||||
isc_boolean_t maximum_reached; /*%< Private. */
|
||||
} isc_logfile_t;
|
||||
|
||||
/*%
|
||||
* Passed to isc_log_createchannel to define the attributes of either
|
||||
* a stdio or a syslog log.
|
||||
*/
|
||||
typedef union isc_logdestination {
|
||||
isc_logfile_t file;
|
||||
int facility; /* XXXDCL NT */
|
||||
} isc_logdestination_t;
|
||||
|
||||
/*@{*/
|
||||
/*%
|
||||
* The built-in categories of libisc.
|
||||
*
|
||||
* Each library registering categories should provide library_LOGCATEGORY_name
|
||||
* definitions with indexes into its isc_logcategory structure corresponding to
|
||||
* the order of the names.
|
||||
*/
|
||||
LIBISC_EXTERNAL_DATA extern isc_logcategory_t isc_categories[];
|
||||
LIBISC_EXTERNAL_DATA extern isc_log_t *isc_lctx;
|
||||
LIBISC_EXTERNAL_DATA extern isc_logmodule_t isc_modules[];
|
||||
/*@}*/
|
||||
|
||||
/*@{*/
|
||||
/*%
|
||||
* Do not log directly to DEFAULT. Use another category. When in doubt,
|
||||
* use GENERAL.
|
||||
*/
|
||||
#define ISC_LOGCATEGORY_DEFAULT (&isc_categories[0])
|
||||
#define ISC_LOGCATEGORY_GENERAL (&isc_categories[1])
|
||||
/*@}*/
|
||||
|
||||
#define ISC_LOGMODULE_SOCKET (&isc_modules[0])
|
||||
#define ISC_LOGMODULE_TIME (&isc_modules[1])
|
||||
#define ISC_LOGMODULE_INTERFACE (&isc_modules[2])
|
||||
#define ISC_LOGMODULE_TIMER (&isc_modules[3])
|
||||
#define ISC_LOGMODULE_FILE (&isc_modules[4])
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
isc_log_create(isc_mem_t *mctx, isc_log_t **lctxp, isc_logconfig_t **lcfgp);
|
||||
/*%<
|
||||
* Establish a new logging context, with default channels.
|
||||
*
|
||||
* Notes:
|
||||
*\li isc_log_create() calls isc_logconfig_create(), so see its comment
|
||||
* below for more information.
|
||||
*
|
||||
* Requires:
|
||||
*\li mctx is a valid memory context.
|
||||
*\li lctxp is not null and *lctxp is null.
|
||||
*\li lcfgp is null or lcfgp is not null and *lcfgp is null.
|
||||
*
|
||||
* Ensures:
|
||||
*\li *lctxp will point to a valid logging context if all of the necessary
|
||||
* memory was allocated, or NULL otherwise.
|
||||
*\li *lcfgp will point to a valid logging configuration if all of the
|
||||
* necessary memory was allocated, or NULL otherwise.
|
||||
*\li On failure, no additional memory is allocated.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS Success
|
||||
*\li #ISC_R_NOMEMORY Resource limit: Out of memory
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp);
|
||||
/*%<
|
||||
* Create the data structure that holds all of the configurable information
|
||||
* about where messages are actually supposed to be sent -- the information
|
||||
* that could changed based on some configuration file, as opposed to the
|
||||
* the category/module specification of isc_log_[v]write[1] that is compiled
|
||||
* into a program, or the debug_level which is dynamic state information.
|
||||
*
|
||||
* Notes:
|
||||
*\li It is necessary to specify the logging context the configuration
|
||||
* will be used with because the number of categories and modules
|
||||
* needs to be known in order to set the configuration. However,
|
||||
* the configuration is not used by the logging context until the
|
||||
* isc_logconfig_use function is called.
|
||||
*
|
||||
*\li The memory context used for operations that allocate memory for
|
||||
* the configuration is that of the logging context, as specified
|
||||
* in the isc_log_create call.
|
||||
*
|
||||
*\li Four default channels are established:
|
||||
*\verbatim
|
||||
* default_syslog
|
||||
* - log to syslog's daemon facility #ISC_LOG_INFO or higher
|
||||
* default_stderr
|
||||
* - log to stderr #ISC_LOG_INFO or higher
|
||||
* default_debug
|
||||
* - log to stderr #ISC_LOG_DEBUG dynamically
|
||||
* null
|
||||
* - log nothing
|
||||
*\endverbatim
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid logging context.
|
||||
*\li lcftp is not null and *lcfgp is null.
|
||||
*
|
||||
* Ensures:
|
||||
*\li *lcfgp will point to a valid logging context if all of the necessary
|
||||
* memory was allocated, or NULL otherwise.
|
||||
*\li On failure, no additional memory is allocated.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS Success
|
||||
*\li #ISC_R_NOMEMORY Resource limit: Out of memory
|
||||
*/
|
||||
|
||||
isc_logconfig_t *
|
||||
isc_logconfig_get(isc_log_t *lctx);
|
||||
/*%<
|
||||
* Returns a pointer to the configuration currently in use by the log context.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid context.
|
||||
*
|
||||
* Ensures:
|
||||
*\li The configuration pointer is non-null.
|
||||
*
|
||||
* Returns:
|
||||
*\li The configuration pointer.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_logconfig_use(isc_log_t *lctx, isc_logconfig_t *lcfg);
|
||||
/*%<
|
||||
* Associate a new configuration with a logging context.
|
||||
*
|
||||
* Notes:
|
||||
*\li This is thread safe. The logging context will lock a mutex
|
||||
* before attempting to swap in the new configuration, and isc_log_doit
|
||||
* (the internal function used by all of isc_log_[v]write[1]) locks
|
||||
* the same lock for the duration of its use of the configuration.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid logging context.
|
||||
*\li lcfg is a valid logging configuration.
|
||||
*\li lctx is the same configuration given to isc_logconfig_create
|
||||
* when the configuration was created.
|
||||
*
|
||||
* Ensures:
|
||||
*\li Future calls to isc_log_write will use the new configuration.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS Success
|
||||
*\li #ISC_R_NOMEMORY Resource limit: Out of memory
|
||||
*/
|
||||
|
||||
void
|
||||
isc_log_destroy(isc_log_t **lctxp);
|
||||
/*%<
|
||||
* Deallocate the memory associated with a logging context.
|
||||
*
|
||||
* Requires:
|
||||
*\li *lctx is a valid logging context.
|
||||
*
|
||||
* Ensures:
|
||||
*\li All of the memory associated with the logging context is returned
|
||||
* to the free memory pool.
|
||||
*
|
||||
*\li Any open files are closed.
|
||||
*
|
||||
*\li The logging context is marked as invalid.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_logconfig_destroy(isc_logconfig_t **lcfgp);
|
||||
/*%<
|
||||
* Destroy a logging configuration.
|
||||
*
|
||||
* Notes:
|
||||
*\li This function cannot be used directly with the return value of
|
||||
* isc_logconfig_get, because a logging context must always have
|
||||
* a valid configuration associated with it.
|
||||
*
|
||||
* Requires:
|
||||
*\li lcfgp is not null and *lcfgp is a valid logging configuration.
|
||||
*\li The logging configuration is not in use by an existing logging context.
|
||||
*
|
||||
* Ensures:
|
||||
*\li All memory allocated for the configuration is freed.
|
||||
*
|
||||
*\li The configuration is marked as invalid.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_log_registercategories(isc_log_t *lctx, isc_logcategory_t categories[]);
|
||||
/*%<
|
||||
* Identify logging categories a library will use.
|
||||
*
|
||||
* Notes:
|
||||
*\li A category should only be registered once, but no mechanism enforces
|
||||
* this rule.
|
||||
*
|
||||
*\li The end of the categories array is identified by a NULL name.
|
||||
*
|
||||
*\li Because the name is used by #ISC_LOG_PRINTCATEGORY, it should not
|
||||
* be altered or destroyed after isc_log_registercategories().
|
||||
*
|
||||
*\li Because each element of the categories array is used by
|
||||
* isc_log_categorybyname, it should not be altered or destroyed
|
||||
* after registration.
|
||||
*
|
||||
*\li The value of the id integer in each structure is overwritten
|
||||
* by this function, and so id need not be initialized to any particular
|
||||
* value prior to the function call.
|
||||
*
|
||||
*\li A subsequent call to isc_log_registercategories with the same
|
||||
* logging context (but new categories) will cause the last
|
||||
* element of the categories array from the prior call to have
|
||||
* its "name" member changed from NULL to point to the new
|
||||
* categories array, and its "id" member set to UINT_MAX.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid logging context.
|
||||
*\li categories != NULL.
|
||||
*\li categories[0].name != NULL.
|
||||
*
|
||||
* Ensures:
|
||||
* \li There are references to each category in the logging context,
|
||||
* so they can be used with isc_log_usechannel() and isc_log_write().
|
||||
*/
|
||||
|
||||
void
|
||||
isc_log_registermodules(isc_log_t *lctx, isc_logmodule_t modules[]);
|
||||
/*%<
|
||||
* Identify logging categories a library will use.
|
||||
*
|
||||
* Notes:
|
||||
*\li A module should only be registered once, but no mechanism enforces
|
||||
* this rule.
|
||||
*
|
||||
*\li The end of the modules array is identified by a NULL name.
|
||||
*
|
||||
*\li Because the name is used by #ISC_LOG_PRINTMODULE, it should not
|
||||
* be altered or destroyed after isc_log_registermodules().
|
||||
*
|
||||
*\li Because each element of the modules array is used by
|
||||
* isc_log_modulebyname, it should not be altered or destroyed
|
||||
* after registration.
|
||||
*
|
||||
*\li The value of the id integer in each structure is overwritten
|
||||
* by this function, and so id need not be initialized to any particular
|
||||
* value prior to the function call.
|
||||
*
|
||||
*\li A subsequent call to isc_log_registermodules with the same
|
||||
* logging context (but new modules) will cause the last
|
||||
* element of the modules array from the prior call to have
|
||||
* its "name" member changed from NULL to point to the new
|
||||
* modules array, and its "id" member set to UINT_MAX.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid logging context.
|
||||
*\li modules != NULL.
|
||||
*\li modules[0].name != NULL;
|
||||
*
|
||||
* Ensures:
|
||||
*\li Each module has a reference in the logging context, so they can be
|
||||
* used with isc_log_usechannel() and isc_log_write().
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_log_createchannel(isc_logconfig_t *lcfg, const char *name,
|
||||
unsigned int type, int level,
|
||||
const isc_logdestination_t *destination,
|
||||
unsigned int flags);
|
||||
/*%<
|
||||
* Specify the parameters of a logging channel.
|
||||
*
|
||||
* Notes:
|
||||
*\li The name argument is copied to memory in the logging context, so
|
||||
* it can be altered or destroyed after isc_log_createchannel().
|
||||
*
|
||||
*\li Defining a very large number of channels will have a performance
|
||||
* impact on isc_log_usechannel(), since the names are searched
|
||||
* linearly until a match is made. This same issue does not affect
|
||||
* isc_log_write, however.
|
||||
*
|
||||
*\li Channel names can be redefined; this is primarily useful for programs
|
||||
* that want their own definition of default_syslog, default_debug
|
||||
* and default_stderr.
|
||||
*
|
||||
*\li Any channel that is redefined will not affect logging that was
|
||||
* already directed to its original definition, _except_ for the
|
||||
* default_stderr channel. This case is handled specially so that
|
||||
* the default logging category can be changed by redefining
|
||||
* default_stderr. (XXXDCL Though now that I think of it, the default
|
||||
* logging category can be changed with only one additional function
|
||||
* call by defining a new channel and then calling isc_log_usechannel()
|
||||
* for #ISC_LOGCATEGORY_DEFAULT.)
|
||||
*
|
||||
*\li Specifying #ISC_LOG_PRINTTIME or #ISC_LOG_PRINTTAG for syslog is allowed,
|
||||
* but probably not what you wanted to do.
|
||||
*
|
||||
* #ISC_LOG_DEBUGONLY will mark the channel as usable only when the
|
||||
* debug level of the logging context (see isc_log_setdebuglevel)
|
||||
* is non-zero.
|
||||
*
|
||||
* Requires:
|
||||
*\li lcfg is a valid logging configuration.
|
||||
*
|
||||
*\li name is not NULL.
|
||||
*
|
||||
*\li type is #ISC_LOG_TOSYSLOG, #ISC_LOG_TOFILE, #ISC_LOG_TOFILEDESC or
|
||||
* #ISC_LOG_TONULL.
|
||||
*
|
||||
*\li destination is not NULL unless type is #ISC_LOG_TONULL.
|
||||
*
|
||||
*\li level is >= #ISC_LOG_CRITICAL (the most negative logging level).
|
||||
*
|
||||
*\li flags does not include any bits aside from the ISC_LOG_PRINT* bits
|
||||
* or #ISC_LOG_DEBUGONLY.
|
||||
*
|
||||
* Ensures:
|
||||
*\li #ISC_R_SUCCESS
|
||||
* A channel with the given name is usable with
|
||||
* isc_log_usechannel().
|
||||
*
|
||||
*\li #ISC_R_NOMEMORY or #ISC_R_UNEXPECTED
|
||||
* No additional memory is being used by the logging context.
|
||||
* Any channel that previously existed with the given name
|
||||
* is not redefined.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS Success
|
||||
*\li #ISC_R_NOMEMORY Resource limit: Out of memory
|
||||
*\li #ISC_R_UNEXPECTED type was out of range and REQUIRE()
|
||||
* was disabled.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_log_usechannel(isc_logconfig_t *lcfg, const char *name,
|
||||
const isc_logcategory_t *category,
|
||||
const isc_logmodule_t *module);
|
||||
/*%<
|
||||
* Associate a named logging channel with a category and module that
|
||||
* will use it.
|
||||
*
|
||||
* Notes:
|
||||
*\li The name is searched for linearly in the set of known channel names
|
||||
* until a match is found. (Note the performance impact of a very large
|
||||
* number of named channels.) When multiple channels of the same
|
||||
* name are defined, the most recent definition is found.
|
||||
*
|
||||
*\li Specifying a very large number of channels for a category will have
|
||||
* a moderate impact on performance in isc_log_write(), as each
|
||||
* call looks up the category for the start of a linked list, which
|
||||
* it follows all the way to the end to find matching modules. The
|
||||
* test for matching modules is integral, though.
|
||||
*
|
||||
*\li If category is NULL, then the channel is associated with the indicated
|
||||
* module for all known categories (including the "default" category).
|
||||
*
|
||||
*\li If module is NULL, then the channel is associated with every module
|
||||
* that uses that category.
|
||||
*
|
||||
*\li Passing both category and module as NULL would make every log message
|
||||
* use the indicated channel.
|
||||
*
|
||||
* \li Specifying a channel that is #ISC_LOG_TONULL for a category/module pair
|
||||
* has no effect on any other channels associated with that pair,
|
||||
* regardless of ordering. Thus you cannot use it to "mask out" one
|
||||
* category/module pair when you have specified some other channel that
|
||||
* is also used by that category/module pair.
|
||||
*
|
||||
* Requires:
|
||||
*\li lcfg is a valid logging configuration.
|
||||
*
|
||||
*\li category is NULL or has an id that is in the range of known ids.
|
||||
*
|
||||
* module is NULL or has an id that is in the range of known ids.
|
||||
*
|
||||
* Ensures:
|
||||
*\li #ISC_R_SUCCESS
|
||||
* The channel will be used by the indicated category/module
|
||||
* arguments.
|
||||
*
|
||||
*\li #ISC_R_NOMEMORY
|
||||
* If assignment for a specific category has been requested,
|
||||
* the channel has not been associated with the indicated
|
||||
* category/module arguments and no additional memory is
|
||||
* used by the logging context.
|
||||
* If assignment for all categories has been requested
|
||||
* then _some_ may have succeeded (starting with category
|
||||
* "default" and progressing through the order of categories
|
||||
* passed to isc_log_registercategories()) and additional memory
|
||||
* is being used by whatever assignments succeeded.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS Success
|
||||
*\li #ISC_R_NOMEMORY Resource limit: Out of memory
|
||||
*/
|
||||
|
||||
/* Attention: next four comments PRECEED code */
|
||||
/*!
|
||||
* \brief
|
||||
* Write a message to the log channels.
|
||||
*
|
||||
* Notes:
|
||||
*\li Log messages containing natural language text should be logged with
|
||||
* isc_log_iwrite() to allow for localization.
|
||||
*
|
||||
*\li lctx can be NULL; this is allowed so that programs which use
|
||||
* libraries that use the ISC logging system are not required to
|
||||
* also use it.
|
||||
*
|
||||
*\li The format argument is a printf(3) string, with additional arguments
|
||||
* as necessary.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid logging context.
|
||||
*
|
||||
*\li The category and module arguments must have ids that are in the
|
||||
* range of known ids, as established by isc_log_registercategories()
|
||||
* and isc_log_registermodules().
|
||||
*
|
||||
*\li level != #ISC_LOG_DYNAMIC. ISC_LOG_DYNAMIC is used only to define
|
||||
* channels, and explicit debugging level must be identified for
|
||||
* isc_log_write() via ISC_LOG_DEBUG(level).
|
||||
*
|
||||
*\li format != NULL.
|
||||
*
|
||||
* Ensures:
|
||||
*\li The log message is written to every channel associated with the
|
||||
* indicated category/module pair.
|
||||
*
|
||||
* Returns:
|
||||
*\li Nothing. Failure to log a message is not construed as a
|
||||
* meaningful error.
|
||||
*/
|
||||
void
|
||||
isc_log_write(isc_log_t *lctx, isc_logcategory_t *category,
|
||||
isc_logmodule_t *module, int level,
|
||||
const char *format, ...)
|
||||
|
||||
ISC_FORMAT_PRINTF(5, 6);
|
||||
|
||||
/*%
|
||||
* Write a message to the log channels.
|
||||
*
|
||||
* Notes:
|
||||
*\li lctx can be NULL; this is allowed so that programs which use
|
||||
* libraries that use the ISC logging system are not required to
|
||||
* also use it.
|
||||
*
|
||||
*\li The format argument is a printf(3) string, with additional arguments
|
||||
* as necessary.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid logging context.
|
||||
*
|
||||
*\li The category and module arguments must have ids that are in the
|
||||
* range of known ids, as established by isc_log_registercategories()
|
||||
* and isc_log_registermodules().
|
||||
*
|
||||
*\li level != #ISC_LOG_DYNAMIC. ISC_LOG_DYNAMIC is used only to define
|
||||
* channels, and explicit debugging level must be identified for
|
||||
* isc_log_write() via ISC_LOG_DEBUG(level).
|
||||
*
|
||||
*\li format != NULL.
|
||||
*
|
||||
* Ensures:
|
||||
*\li The log message is written to every channel associated with the
|
||||
* indicated category/module pair.
|
||||
*
|
||||
* Returns:
|
||||
*\li Nothing. Failure to log a message is not construed as a
|
||||
* meaningful error.
|
||||
*/
|
||||
void
|
||||
isc_log_vwrite(isc_log_t *lctx, isc_logcategory_t *category,
|
||||
isc_logmodule_t *module, int level,
|
||||
const char *format, va_list args)
|
||||
|
||||
ISC_FORMAT_PRINTF(5, 0);
|
||||
|
||||
/*%
|
||||
* Write a message to the log channels, pruning duplicates that occur within
|
||||
* a configurable amount of seconds (see isc_log_[sg]etduplicateinterval).
|
||||
* This function is otherwise identical to isc_log_write().
|
||||
*/
|
||||
void
|
||||
isc_log_write1(isc_log_t *lctx, isc_logcategory_t *category,
|
||||
isc_logmodule_t *module, int level, const char *format, ...)
|
||||
|
||||
ISC_FORMAT_PRINTF(5, 6);
|
||||
|
||||
/*%
|
||||
* Write a message to the log channels, pruning duplicates that occur within
|
||||
* a configurable amount of seconds (see isc_log_[sg]etduplicateinterval).
|
||||
* This function is otherwise identical to isc_log_vwrite().
|
||||
*/
|
||||
void
|
||||
isc_log_vwrite1(isc_log_t *lctx, isc_logcategory_t *category,
|
||||
isc_logmodule_t *module, int level, const char *format,
|
||||
va_list args)
|
||||
|
||||
ISC_FORMAT_PRINTF(5, 0);
|
||||
|
||||
/*%
|
||||
* These are four internationalized versions of the isc_log_[v]write[1]
|
||||
* functions.
|
||||
*
|
||||
* The only difference is that they take arguments for a message
|
||||
* catalog, message set, and message number, all immediately preceding the
|
||||
* format argument. The format argument becomes the default text, a la
|
||||
* isc_msgcat_get. If the message catalog is NULL, no lookup is attempted
|
||||
* for a message -- which makes the message set and message number irrelevant,
|
||||
* and the non-internationalized call should have probably been used instead.
|
||||
*
|
||||
* Yes, that means there are now *eight* interfaces to logging a message.
|
||||
* Sheesh. Make the madness stop!
|
||||
*/
|
||||
/*@{*/
|
||||
void
|
||||
isc_log_iwrite(isc_log_t *lctx, isc_logcategory_t *category,
|
||||
isc_logmodule_t *module, int level,
|
||||
isc_msgcat_t *msgcat, int msgset, int message,
|
||||
const char *format, ...)
|
||||
ISC_FORMAT_PRINTF(8, 9);
|
||||
|
||||
void
|
||||
isc_log_ivwrite(isc_log_t *lctx, isc_logcategory_t *category,
|
||||
isc_logmodule_t *module, int level,
|
||||
isc_msgcat_t *msgcat, int msgset, int message,
|
||||
const char *format, va_list args)
|
||||
ISC_FORMAT_PRINTF(8, 0);
|
||||
|
||||
void
|
||||
isc_log_iwrite1(isc_log_t *lctx, isc_logcategory_t *category,
|
||||
isc_logmodule_t *module, int level,
|
||||
isc_msgcat_t *msgcat, int msgset, int message,
|
||||
const char *format, ...)
|
||||
ISC_FORMAT_PRINTF(8, 9);
|
||||
|
||||
void
|
||||
isc_log_ivwrite1(isc_log_t *lctx, isc_logcategory_t *category,
|
||||
isc_logmodule_t *module, int level,
|
||||
isc_msgcat_t *msgcat, int msgset, int message,
|
||||
const char *format, va_list args)
|
||||
ISC_FORMAT_PRINTF(8, 0);
|
||||
/*@}*/
|
||||
|
||||
void
|
||||
isc_log_setdebuglevel(isc_log_t *lctx, unsigned int level);
|
||||
/*%<
|
||||
* Set the debugging level used for logging.
|
||||
*
|
||||
* Notes:
|
||||
*\li Setting the debugging level to 0 disables debugging log messages.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid logging context.
|
||||
*
|
||||
* Ensures:
|
||||
*\li The debugging level is set to the requested value.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_log_getdebuglevel(isc_log_t *lctx);
|
||||
/*%<
|
||||
* Get the current debugging level.
|
||||
*
|
||||
* Notes:
|
||||
*\li This is provided so that a program can have a notion of
|
||||
* "increment debugging level" or "decrement debugging level"
|
||||
* without needing to keep track of what the current level is.
|
||||
*
|
||||
*\li A return value of 0 indicates that debugging messages are disabled.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid logging context.
|
||||
*
|
||||
* Ensures:
|
||||
*\li The current logging debugging level is returned.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_log_wouldlog(isc_log_t *lctx, int level);
|
||||
/*%<
|
||||
* Determine whether logging something to 'lctx' at 'level' would
|
||||
* actually cause something to be logged somewhere.
|
||||
*
|
||||
* If #ISC_FALSE is returned, it is guaranteed that nothing would
|
||||
* be logged, allowing the caller to omit unnecessary
|
||||
* isc_log_write() calls and possible message preformatting.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_log_setduplicateinterval(isc_logconfig_t *lcfg, unsigned int interval);
|
||||
/*%<
|
||||
* Set the interval over which duplicate log messages will be ignored
|
||||
* by isc_log_[v]write1(), in seconds.
|
||||
*
|
||||
* Notes:
|
||||
*\li Increasing the duplicate interval from X to Y will not necessarily
|
||||
* filter out duplicates of messages logged in Y - X seconds since the
|
||||
* increase. (Example: Message1 is logged at midnight. Message2
|
||||
* is logged at 00:01:00, when the interval is only 30 seconds, causing
|
||||
* Message1 to be expired from the log message history. Then the interval
|
||||
* is increased to 3000 (five minutes) and at 00:04:00 Message1 is logged
|
||||
* again. It will appear the second time even though less than five
|
||||
* passed since the first occurrence.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid logging context.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_log_getduplicateinterval(isc_logconfig_t *lcfg);
|
||||
/*%<
|
||||
* Get the current duplicate filtering interval.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid logging context.
|
||||
*
|
||||
* Returns:
|
||||
*\li The current duplicate filtering interval.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_log_settag(isc_logconfig_t *lcfg, const char *tag);
|
||||
/*%<
|
||||
* Set the program name or other identifier for #ISC_LOG_PRINTTAG.
|
||||
*
|
||||
* Requires:
|
||||
*\li lcfg is a valid logging configuration.
|
||||
*
|
||||
* Notes:
|
||||
*\li If this function has not set the tag to a non-NULL, non-empty value,
|
||||
* then the #ISC_LOG_PRINTTAG channel flag will not print anything.
|
||||
* Unlike some implementations of syslog on Unix systems, you *must* set
|
||||
* the tag in order to get it logged. It is not implicitly derived from
|
||||
* the program name (which is pretty impossible to infer portably).
|
||||
*
|
||||
*\li Setting the tag to NULL or the empty string will also cause the
|
||||
* #ISC_LOG_PRINTTAG channel flag to not print anything. If tag equals the
|
||||
* empty string, calls to isc_log_gettag will return NULL.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS Success
|
||||
*\li #ISC_R_NOMEMORY Resource Limit: Out of memory
|
||||
*
|
||||
* XXXDCL when creating a new isc_logconfig_t, it might be nice if the tag
|
||||
* of the currently active isc_logconfig_t was inherited. this does not
|
||||
* currently happen.
|
||||
*/
|
||||
|
||||
char *
|
||||
isc_log_gettag(isc_logconfig_t *lcfg);
|
||||
/*%<
|
||||
* Get the current identifier printed with #ISC_LOG_PRINTTAG.
|
||||
*
|
||||
* Requires:
|
||||
*\li lcfg is a valid logging configuration.
|
||||
*
|
||||
* Notes:
|
||||
*\li Since isc_log_settag() will not associate a zero-length string
|
||||
* with the logging configuration, attempts to do so will cause
|
||||
* this function to return NULL. However, a determined programmer
|
||||
* will observe that (currently) a tag of length greater than zero
|
||||
* could be set, and then modified to be zero length.
|
||||
*
|
||||
* Returns:
|
||||
*\li A pointer to the current identifier, or NULL if none has been set.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_log_opensyslog(const char *tag, int options, int facility);
|
||||
/*%<
|
||||
* Initialize syslog logging.
|
||||
*
|
||||
* Notes:
|
||||
*\li XXXDCL NT
|
||||
* This is currently equivalent to openlog(), but is not going to remain
|
||||
* that way. In the meantime, the arguments are all identical to
|
||||
* those used by openlog(3), as follows:
|
||||
*
|
||||
* \code
|
||||
* tag: The string to use in the position of the program
|
||||
* name in syslog messages. Most (all?) syslogs
|
||||
* will use basename(argv[0]) if tag is NULL.
|
||||
*
|
||||
* options: LOG_CONS, LOG_PID, LOG_NDELAY ... whatever your
|
||||
* syslog supports.
|
||||
*
|
||||
* facility: The default syslog facility. This is irrelevant
|
||||
* since isc_log_write will ALWAYS use the channel's
|
||||
* declared facility.
|
||||
* \endcode
|
||||
*
|
||||
*\li Zero effort has been made (yet) to accommodate systems with openlog()
|
||||
* that only takes two arguments, or to identify valid syslog
|
||||
* facilities or options for any given architecture.
|
||||
*
|
||||
*\li It is necessary to call isc_log_opensyslog() to initialize
|
||||
* syslogging on machines which do not support network connections to
|
||||
* syslogd because they require a Unix domain socket to be used. Since
|
||||
* this is a chore to determine at run-time, it is suggested that it
|
||||
* always be called by programs using the ISC logging system.
|
||||
*
|
||||
* Requires:
|
||||
*\li Nothing.
|
||||
*
|
||||
* Ensures:
|
||||
*\li openlog() is called to initialize the syslog system.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_log_closefilelogs(isc_log_t *lctx);
|
||||
/*%<
|
||||
* Close all open files used by #ISC_LOG_TOFILE channels.
|
||||
*
|
||||
* Notes:
|
||||
*\li This function is provided for programs that want to use their own
|
||||
* log rolling mechanism rather than the one provided internally.
|
||||
* For example, a program that wanted to keep daily logs would define
|
||||
* a channel which used #ISC_LOG_ROLLNEVER, then once a day would
|
||||
* rename the log file and call isc_log_closefilelogs().
|
||||
*
|
||||
*\li #ISC_LOG_TOFILEDESC channels are unaffected.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid context.
|
||||
*
|
||||
* Ensures:
|
||||
*\li The open files are closed and will be reopened when they are
|
||||
* next needed.
|
||||
*/
|
||||
|
||||
isc_logcategory_t *
|
||||
isc_log_categorybyname(isc_log_t *lctx, const char *name);
|
||||
/*%<
|
||||
* Find a category by its name.
|
||||
*
|
||||
* Notes:
|
||||
*\li The string name of a category is not required to be unique.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid context.
|
||||
*\li name is not NULL.
|
||||
*
|
||||
* Returns:
|
||||
*\li A pointer to the _first_ isc_logcategory_t structure used by "name".
|
||||
*
|
||||
*\li NULL if no category exists by that name.
|
||||
*/
|
||||
|
||||
isc_logmodule_t *
|
||||
isc_log_modulebyname(isc_log_t *lctx, const char *name);
|
||||
/*%<
|
||||
* Find a module by its name.
|
||||
*
|
||||
* Notes:
|
||||
*\li The string name of a module is not required to be unique.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid context.
|
||||
*\li name is not NULL.
|
||||
*
|
||||
* Returns:
|
||||
*\li A pointer to the _first_ isc_logmodule_t structure used by "name".
|
||||
*
|
||||
*\li NULL if no module exists by that name.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_log_setcontext(isc_log_t *lctx);
|
||||
/*%<
|
||||
* Sets the context used by the libisc for logging.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx be a valid context.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_LOG_H */
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: magic.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_MAGIC_H
|
||||
#define ISC_MAGIC_H 1
|
||||
|
||||
/*! \file isc/magic.h */
|
||||
|
||||
typedef struct {
|
||||
unsigned int magic;
|
||||
} isc__magic_t;
|
||||
|
||||
|
||||
/*%
|
||||
* To use this macro the magic number MUST be the first thing in the
|
||||
* structure, and MUST be of type "unsigned int".
|
||||
* The intent of this is to allow magic numbers to be checked even though
|
||||
* the object is otherwise opaque.
|
||||
*/
|
||||
#define ISC_MAGIC_VALID(a,b) (((a) != NULL) && \
|
||||
(((const isc__magic_t *)(a))->magic == (b)))
|
||||
|
||||
#define ISC_MAGIC(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))
|
||||
|
||||
#endif /* ISC_MAGIC_H */
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009, 2010 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: md5.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
/*! \file isc/md5.h
|
||||
* \brief This is the header file for the MD5 message-digest algorithm.
|
||||
*
|
||||
* The algorithm is due to Ron Rivest. This code was
|
||||
* written by Colin Plumb in 1993, no copyright is claimed.
|
||||
* This code is in the public domain; do with it what you wish.
|
||||
*
|
||||
* Equivalent code is available from RSA Data Security, Inc.
|
||||
* This code has been tested against that, and is equivalent,
|
||||
* except that you don't need to include two pages of legalese
|
||||
* with every copy.
|
||||
*
|
||||
* To compute the message digest of a chunk of bytes, declare an
|
||||
* MD5Context structure, pass it to MD5Init, call MD5Update as
|
||||
* needed on buffers full of bytes, and then call MD5Final, which
|
||||
* will fill a supplied 16-byte array with the digest.
|
||||
*
|
||||
* Changed so as no longer to depend on Colin Plumb's `usual.h'
|
||||
* header definitions; now uses stuff from dpkg's config.h
|
||||
* - Ian Jackson <ijackson@nyx.cs.du.edu>.
|
||||
* Still in the public domain.
|
||||
*/
|
||||
|
||||
#ifndef ISC_MD5_H
|
||||
#define ISC_MD5_H 1
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#define ISC_MD5_DIGESTLENGTH 16U
|
||||
#define ISC_MD5_BLOCK_LENGTH 64U
|
||||
|
||||
#ifdef ISC_PLATFORM_OPENSSLHASH
|
||||
#include <openssl/evp.h>
|
||||
|
||||
typedef EVP_MD_CTX isc_md5_t;
|
||||
|
||||
#else
|
||||
|
||||
typedef struct {
|
||||
isc_uint32_t buf[4];
|
||||
isc_uint32_t bytes[2];
|
||||
isc_uint32_t in[16];
|
||||
} isc_md5_t;
|
||||
#endif
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
void
|
||||
isc_md5_init(isc_md5_t *ctx);
|
||||
|
||||
void
|
||||
isc_md5_invalidate(isc_md5_t *ctx);
|
||||
|
||||
void
|
||||
isc_md5_update(isc_md5_t *ctx, const unsigned char *buf, unsigned int len);
|
||||
|
||||
void
|
||||
isc_md5_final(isc_md5_t *ctx, unsigned char *digest);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_MD5_H */
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: msgcat.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_MSGCAT_H
|
||||
#define ISC_MSGCAT_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/msgcat.h
|
||||
* \brief The ISC Message Catalog
|
||||
* aids internationalization of applications by allowing
|
||||
* messages to be retrieved from locale-specific files instead of
|
||||
* hardwiring them into the application. This allows translations of
|
||||
* messages appropriate to the locale to be supplied without recompiling
|
||||
* the application.
|
||||
*
|
||||
* Notes:
|
||||
*\li It's very important that message catalogs work, even if only the
|
||||
* default_text can be used.
|
||||
*
|
||||
* MP:
|
||||
*\li The caller must ensure appropriate synchronization of
|
||||
* isc_msgcat_open() and isc_msgcat_close(). isc_msgcat_get()
|
||||
* ensures appropriate synchronization.
|
||||
*
|
||||
* Reliability:
|
||||
*\li No anticipated impact.
|
||||
*
|
||||
* Resources:
|
||||
*\li TBS
|
||||
*
|
||||
* \li Security:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Standards:
|
||||
* None.
|
||||
*/
|
||||
|
||||
/*****
|
||||
***** Imports
|
||||
*****/
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*****
|
||||
***** Methods
|
||||
*****/
|
||||
|
||||
void
|
||||
isc_msgcat_open(const char *name, isc_msgcat_t **msgcatp);
|
||||
/*%<
|
||||
* Open a message catalog.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li If memory cannot be allocated or other failures occur, *msgcatp
|
||||
* will be set to NULL. If a NULL msgcat is given to isc_msgcat_get(),
|
||||
* the default_text will be returned, ensuring that some message text
|
||||
* will be available, no matter what's going wrong.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'name' is a valid string.
|
||||
*
|
||||
*\li msgcatp != NULL && *msgcatp == NULL
|
||||
*/
|
||||
|
||||
void
|
||||
isc_msgcat_close(isc_msgcat_t **msgcatp);
|
||||
/*%<
|
||||
* Close a message catalog.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li Any string pointers returned by prior calls to isc_msgcat_get() are
|
||||
* invalid after isc_msgcat_close() has been called and must not be
|
||||
* used.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li *msgcatp is a valid message catalog or is NULL.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li All resources associated with the message catalog are released.
|
||||
*
|
||||
*\li *msgcatp == NULL
|
||||
*/
|
||||
|
||||
const char *
|
||||
isc_msgcat_get(isc_msgcat_t *msgcat, int set, int message,
|
||||
const char *default_text);
|
||||
/*%<
|
||||
* Get message 'message' from message set 'set' in 'msgcat'. If it
|
||||
* is not available, use 'default_text'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'msgcat' is a valid message catalog or is NULL.
|
||||
*
|
||||
*\li set > 0
|
||||
*
|
||||
*\li message > 0
|
||||
*
|
||||
*\li 'default_text' is a valid string.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_MSGCAT_H */
|
||||
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000-2003 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: msgs.h,v 1.2.10.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_MSGS_H
|
||||
#define ISC_MSGS_H 1
|
||||
|
||||
/*! \file isc/msgs.h */
|
||||
|
||||
#include <isc/isc_lib.h> /* Provide isc_msgcat global variable. */
|
||||
#include <isc/msgcat.h> /* Provide isc_msgcat_*() functions. */
|
||||
|
||||
/*@{*/
|
||||
/*!
|
||||
* \brief Message sets, named per source file, excepting "GENERAL".
|
||||
*
|
||||
* IMPORTANT: The original list is alphabetical, but any new sets must
|
||||
* be added to the end.
|
||||
*/
|
||||
#define ISC_MSGSET_GENERAL 1
|
||||
/* ISC_RESULT_RESULTSET 2 */ /* XXX */
|
||||
/* ISC_RESULT_UNAVAILABLESET 3 */ /* XXX */
|
||||
#define ISC_MSGSET_APP 4
|
||||
#define ISC_MSGSET_COMMANDLINE 5
|
||||
#define ISC_MSGSET_ENTROPY 6
|
||||
#define ISC_MSGSET_IFITERIOCTL 7
|
||||
#define ISC_MSGSET_IFITERSYSCTL 8
|
||||
#define ISC_MSGSET_LEX 9
|
||||
#define ISC_MSGSET_LOG 10
|
||||
#define ISC_MSGSET_MEM 11
|
||||
#define ISC_MSGSET_NETADDR 12
|
||||
#define ISC_MSGSET_PRINT 13
|
||||
#define ISC_MSGSET_RESULT 14
|
||||
#define ISC_MSGSET_RWLOCK 15
|
||||
#define ISC_MSGSET_SOCKADDR 16
|
||||
#define ISC_MSGSET_SOCKET 17
|
||||
#define ISC_MSGSET_TASK 18
|
||||
#define ISC_MSGSET_TIMER 19
|
||||
#define ISC_MSGSET_UTIL 20
|
||||
#define ISC_MSGSET_IFITERGETIFADDRS 21
|
||||
/*@}*/
|
||||
|
||||
/*@{*/
|
||||
/*!
|
||||
* Message numbers
|
||||
* are only required to be unique per message set,
|
||||
* but are unique throughout the entire catalog to not be as confusing when
|
||||
* debugging.
|
||||
*
|
||||
* The initial numbering was done by multiply by 100 the set number the
|
||||
* message appears in then adding the incremental message number.
|
||||
*/
|
||||
#define ISC_MSG_FAILED 101 /*%< "failed" */
|
||||
#define ISC_MSG_SUCCEEDED 102 /*%< Compatible with "failed" */
|
||||
#define ISC_MSG_SUCCESS 103 /*%< More usual way to say "success" */
|
||||
#define ISC_MSG_STARTING 104 /*%< As in "daemon: starting" */
|
||||
#define ISC_MSG_STOPING 105 /*%< As in "daemon: stopping" */
|
||||
#define ISC_MSG_ENTERING 106 /*%< As in "some_subr: entering" */
|
||||
#define ISC_MSG_EXITING 107 /*%< As in "some_subr: exiting" */
|
||||
#define ISC_MSG_CALLING 108 /*%< As in "calling some_subr()" */
|
||||
#define ISC_MSG_RETURNED 109 /*%< As in "some_subr: returned <foo>" */
|
||||
#define ISC_MSG_FATALERROR 110 /*%< "fatal error" */
|
||||
#define ISC_MSG_SHUTTINGDOWN 111 /*%< "shutting down" */
|
||||
#define ISC_MSG_RUNNING 112 /*%< "running" */
|
||||
#define ISC_MSG_WAIT 113 /*%< "wait" */
|
||||
#define ISC_MSG_WAITUNTIL 114 /*%< "waituntil" */
|
||||
|
||||
#define ISC_MSG_SIGNALSETUP 201 /*%< "handle_signal() %d setup: %s" */
|
||||
|
||||
#define ISC_MSG_ILLEGALOPT 301 /*%< "illegal option" */
|
||||
#define ISC_MSG_OPTNEEDARG 302 /*%< "option requires an argument" */
|
||||
|
||||
#define ISC_MSG_ENTROPYSTATS 401 /*%< "Entropy pool %p: refcnt %u ..." */
|
||||
|
||||
#define ISC_MSG_MAKESCANSOCKET 501 /*%< "making interface scan socket: %s" */
|
||||
#define ISC_MSG_GETIFCONFIG 502 /*%< "get interface configuration: %s" */
|
||||
#define ISC_MSG_BUFFERMAX 503 /*%< "... maximum buffer size exceeded" */
|
||||
#define ISC_MSG_GETDESTADDR 504 /*%< "%s: getting destination address: %s" */
|
||||
#define ISC_MSG_GETNETMASK 505 /*%< "%s: getting netmask: %s" */
|
||||
#define ISC_MSG_GETBCSTADDR 506 /*%< "%s: getting broadcast address: %s" */
|
||||
|
||||
#define ISC_MSG_GETIFLISTSIZE 601 /*%< "getting interface list size: ..." */
|
||||
#define ISC_MSG_GETIFLIST 602 /*%< "getting interface list: ..." */
|
||||
#define ISC_MSG_UNEXPECTEDTYPE 603 /*%< "... unexpected ... message type" */
|
||||
|
||||
#define ISC_MSG_UNEXPECTEDSTATE 701 /*%< "Unexpected state %d" */
|
||||
|
||||
#define ISC_MSG_BADTIME 801 /*%< "Bad 00 99:99:99.999 " */
|
||||
#define ISC_MSG_LEVEL 802 /*%< "level %d: " */
|
||||
|
||||
#define ISC_MSG_ADDTRACE 901 /*%< "add %p size %u " */
|
||||
#define ISC_MSG_DELTRACE 902 /*%< "del %p size %u " */
|
||||
#define ISC_MSG_POOLSTATS 903 /*%< "[Pool statistics]\n" */
|
||||
#define ISC_MSG_POOLNAME 904 /*%< "name" */
|
||||
#define ISC_MSG_POOLSIZE 905 /*%< "size" */
|
||||
#define ISC_MSG_POOLMAXALLOC 906 /*%< "maxalloc" */
|
||||
#define ISC_MSG_POOLALLOCATED 907 /*%< "allocated" */
|
||||
#define ISC_MSG_POOLFREECOUNT 908 /*%< "freecount" */
|
||||
#define ISC_MSG_POOLFREEMAX 909 /*%< "freemax" */
|
||||
#define ISC_MSG_POOLFILLCOUNT 910 /*%< "fillcount" */
|
||||
#define ISC_MSG_POOLGETS 911 /*%< "gets" */
|
||||
#define ISC_MSG_DUMPALLOC 912 /*%< "DUMP OF ALL OUTSTANDING MEMORY ..." */
|
||||
#define ISC_MSG_NONE 913 /*%< "\tNone.\n" */
|
||||
#define ISC_MSG_PTRFILELINE 914 /*%< "\tptr %p file %s line %u\n" */
|
||||
|
||||
#define ISC_MSG_UNKNOWNADDR 1001 /*%< "<unknown address, family %u>" */
|
||||
|
||||
#define ISC_MSG_NOLONGDBL 1104 /*%< "long doubles are not supported" */
|
||||
|
||||
#define ISC_MSG_PRINTLOCK 1201 /*%< "rwlock %p thread %lu ..." */
|
||||
#define ISC_MSG_READ 1202 /*%< "read" */
|
||||
#define ISC_MSG_WRITE 1203 /*%< "write" */
|
||||
#define ISC_MSG_READING 1204 /*%< "reading" */
|
||||
#define ISC_MSG_WRITING 1205 /*%< "writing" */
|
||||
#define ISC_MSG_PRELOCK 1206 /*%< "prelock" */
|
||||
#define ISC_MSG_POSTLOCK 1207 /*%< "postlock" */
|
||||
#define ISC_MSG_PREUNLOCK 1208 /*%< "preunlock" */
|
||||
#define ISC_MSG_POSTUNLOCK 1209 /*%< "postunlock" */
|
||||
|
||||
#define ISC_MSG_UNKNOWNFAMILY 1301 /*%< "unknown address family: %d" */
|
||||
|
||||
#define ISC_MSG_WRITEFAILED 1401 /*%< "write() failed during watcher ..." */
|
||||
#define ISC_MSG_READFAILED 1402 /*%< "read() failed during watcher ... " */
|
||||
#define ISC_MSG_PROCESSCMSG 1403 /*%< "processing cmsg %p" */
|
||||
#define ISC_MSG_IFRECEIVED 1404 /*%< "interface received on ifindex %u" */
|
||||
#define ISC_MSG_SENDTODATA 1405 /*%< "sendto pktinfo data, ifindex %u" */
|
||||
#define ISC_MSG_DOIORECV 1406 /*%< "doio_recv: recvmsg(%d) %d bytes ..." */
|
||||
#define ISC_MSG_PKTRECV 1407 /*%< "packet received correctly" */
|
||||
#define ISC_MSG_DESTROYING 1408 /*%< "destroying" */
|
||||
#define ISC_MSG_CREATED 1409 /*%< "created" */
|
||||
#define ISC_MSG_ACCEPTLOCK 1410 /*%< "internal_accept called, locked ..." */
|
||||
#define ISC_MSG_ACCEPTEDCXN 1411 /*%< "accepted connection, new socket %p" */
|
||||
#define ISC_MSG_INTERNALRECV 1412 /*%< "internal_recv: task %p got event %p" */
|
||||
#define ISC_MSG_INTERNALSEND 1413 /*%< "internal_send: task %p got event %p" */
|
||||
#define ISC_MSG_WATCHERMSG 1414 /*%< "watcher got message %d" */
|
||||
#define ISC_MSG_SOCKETSREMAIN 1415 /*%< "sockets exist" */
|
||||
#define ISC_MSG_PKTINFOPROVIDED 1416 /*%< "pktinfo structure provided, ..." */
|
||||
#define ISC_MSG_BOUND 1417 /*%< "bound" */
|
||||
#define ISC_MSG_ACCEPTRETURNED 1418 /*%< accept() returned %d/%s */
|
||||
#define ISC_MSG_TOOMANYFDS 1419 /*%< %s: too many open file descriptors */
|
||||
#define ISC_MSG_ZEROPORT 1420 /*%< dropping source port zero packet */
|
||||
#define ISC_MSG_FILTER 1421 /*%< setsockopt(SO_ACCEPTFILTER): %s */
|
||||
|
||||
#define ISC_MSG_TOOMANYHANDLES 1422 /*%< %s: too many open WSA event handles: %s */
|
||||
#define ISC_MSG_POKED 1423 /*%< "poked flags: %d" */
|
||||
|
||||
#define ISC_MSG_AWAKE 1502 /*%< "awake" */
|
||||
#define ISC_MSG_WORKING 1503 /*%< "working" */
|
||||
#define ISC_MSG_EXECUTE 1504 /*%< "execute action" */
|
||||
#define ISC_MSG_EMPTY 1505 /*%< "empty" */
|
||||
#define ISC_MSG_DONE 1506 /*%< "done" */
|
||||
#define ISC_MSG_QUANTUM 1507 /*%< "quantum" */
|
||||
|
||||
#define ISC_MSG_SCHEDULE 1601 /*%< "schedule" */
|
||||
#define ISC_MSG_SIGNALSCHED 1602 /*%< "signal (schedule)" */
|
||||
#define ISC_MSG_SIGNALDESCHED 1603 /*%< "signal (deschedule)" */
|
||||
#define ISC_MSG_SIGNALDESTROY 1604 /*%< "signal (destroy)" */
|
||||
#define ISC_MSG_IDLERESCHED 1605 /*%< "idle reschedule" */
|
||||
#define ISC_MSG_EVENTNOTALLOC 1606 /*%< "couldn't allocate event" */
|
||||
#define ISC_MSG_SCHEDFAIL 1607 /*%< "couldn't schedule timer: %u" */
|
||||
#define ISC_MSG_POSTING 1608 /*%< "posting" */
|
||||
#define ISC_MSG_WAKEUP 1609 /*%< "wakeup" */
|
||||
|
||||
#define ISC_MSG_LOCK 1701 /*%< "LOCK" */
|
||||
#define ISC_MSG_LOCKING 1702 /*%< "LOCKING" */
|
||||
#define ISC_MSG_LOCKED 1703 /*%< "LOCKED" */
|
||||
#define ISC_MSG_UNLOCKED 1704 /*%< "UNLOCKED" */
|
||||
#define ISC_MSG_RWLOCK 1705 /*%< "RWLOCK" */
|
||||
#define ISC_MSG_RWLOCKED 1706 /*%< "RWLOCKED" */
|
||||
#define ISC_MSG_RWUNLOCK 1707 /*%< "RWUNLOCK" */
|
||||
#define ISC_MSG_BROADCAST 1708 /*%< "BROADCAST" */
|
||||
#define ISC_MSG_SIGNAL 1709 /*%< "SIGNAL" */
|
||||
#define ISC_MSG_UTILWAIT 1710 /*%< "WAIT" */
|
||||
#define ISC_MSG_WAITED 1711 /*%< "WAITED" */
|
||||
|
||||
#define ISC_MSG_GETIFADDRS 1801 /*%< "getting interface addresses: ..." */
|
||||
|
||||
/*@}*/
|
||||
|
||||
#endif /* ISC_MSGS_H */
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: mutex.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_MUTEX_H
|
||||
#define ISC_MUTEX_H 1
|
||||
|
||||
#include <isc/result.h> /* for ISC_R_ codes */
|
||||
|
||||
typedef int isc_mutex_t;
|
||||
|
||||
#define isc_mutex_init(mp) \
|
||||
(*(mp) = 0, ISC_R_SUCCESS)
|
||||
#define isc_mutex_lock(mp) \
|
||||
((*(mp))++ == 0 ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
#define isc_mutex_unlock(mp) \
|
||||
(--(*(mp)) == 0 ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
|
||||
#define isc_mutex_trylock(mp) \
|
||||
(*(mp) == 0 ? ((*(mp))++, ISC_R_SUCCESS) : ISC_R_LOCKBUSY)
|
||||
#define isc_mutex_destroy(mp) \
|
||||
(*(mp) == 0 ? (*(mp) = -1, ISC_R_SUCCESS) : ISC_R_UNEXPECTED)
|
||||
#define isc_mutex_stats(fp)
|
||||
|
||||
#endif /* ISC_MUTEX_H */
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: mutexblock.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_MUTEXBLOCK_H
|
||||
#define ISC_MUTEXBLOCK_H 1
|
||||
|
||||
/*! \file isc/mutexblock.h */
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
isc_mutexblock_init(isc_mutex_t *block, unsigned int count);
|
||||
/*%<
|
||||
* Initialize a block of locks. If an error occurs all initialized locks
|
||||
* will be destroyed, if possible.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li block != NULL
|
||||
*
|
||||
*\li count > 0
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li Any code isc_mutex_init() can return is a valid return for this
|
||||
* function.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_mutexblock_destroy(isc_mutex_t *block, unsigned int count);
|
||||
/*%<
|
||||
* Destroy a block of locks.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li block != NULL
|
||||
*
|
||||
*\li count > 0
|
||||
*
|
||||
*\li Each lock in the block be initialized via isc_mutex_init() or
|
||||
* the whole block was initialized via isc_mutex_initblock().
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li Any code isc_mutex_init() can return is a valid return for this
|
||||
* function.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_MUTEXBLOCK_H */
|
||||
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: namespace.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISCAPI_NAMESPACE_H
|
||||
#define ISCAPI_NAMESPACE_H 1
|
||||
|
||||
/*%
|
||||
* name space conversions
|
||||
*/
|
||||
|
||||
#ifdef BIND9
|
||||
|
||||
#define isc_app_start isc__app_start
|
||||
#define isc_app_ctxstart isc__app_ctxstart
|
||||
#define isc_app_onrun isc__app_onrun
|
||||
#define isc_app_run isc__app_run
|
||||
#define isc_app_ctxrun isc__app_ctxrun
|
||||
#define isc_app_shutdown isc__app_shutdown
|
||||
#define isc_app_ctxfinish isc__app_ctxfinish
|
||||
#define isc_app_ctxshutdown isc__app_ctxshutdown
|
||||
#define isc_app_ctxsuspend isc__app_ctxsuspend
|
||||
#define isc_app_reload isc__app_reload
|
||||
#define isc_app_finish isc__app_finish
|
||||
#define isc_app_block isc__app_block
|
||||
#define isc_app_unblock isc__app_unblock
|
||||
#define isc_appctx_create isc__appctx_create
|
||||
#define isc_appctx_destroy isc__appctx_destroy
|
||||
#define isc_appctx_settaskmgr isc__appctx_settaskmgr
|
||||
#define isc_appctx_setsocketmgr isc__appctx_setsocketmgr
|
||||
#define isc_appctx_settimermgr isc__appctx_settimermgr
|
||||
|
||||
#define isc_mem_checkdestroyed isc__mem_checkdestroyed
|
||||
#define isc_mem_createx isc__mem_createx
|
||||
#define isc_mem_createx2 isc__mem_createx2
|
||||
#define isc_mem_create isc__mem_create
|
||||
#define isc_mem_create2 isc__mem_create2
|
||||
#define isc_mem_attach isc__mem_attach
|
||||
#define isc_mem_detach isc__mem_detach
|
||||
#define isc__mem_putanddetach isc___mem_putanddetach
|
||||
#define isc_mem_destroy isc__mem_destroy
|
||||
#define isc_mem_ondestroy isc__mem_ondestroy
|
||||
#define isc__mem_get isc___mem_get
|
||||
#define isc__mem_put isc___mem_put
|
||||
#define isc_mem_stats isc__mem_stats
|
||||
#define isc__mem_allocate isc___mem_allocate
|
||||
#define isc__mem_free isc___mem_free
|
||||
#define isc__mem_strdup isc___mem_strdup
|
||||
#define isc__mem_reallocate isc___mem_reallocate
|
||||
#define isc_mem_references isc__mem_references
|
||||
#define isc_mem_setdestroycheck isc__mem_setdestroycheck
|
||||
#define isc_mem_setquota isc__mem_setquota
|
||||
#define isc_mem_getname isc__mem_getname
|
||||
#define isc_mem_getquota isc__mem_getquota
|
||||
#define isc_mem_gettag isc__mem_gettag
|
||||
#define isc_mem_inuse isc__mem_inuse
|
||||
#define isc_mem_isovermem isc__mem_isovermem
|
||||
#define isc_mem_setname isc__mem_setname
|
||||
#define isc_mem_setwater isc__mem_setwater
|
||||
#define isc_mem_printallactive isc__mem_printallactive
|
||||
#define isc_mem_waterack isc__mem_waterack
|
||||
#define isc_mempool_create isc__mempool_create
|
||||
#define isc_mempool_setname isc__mempool_setname
|
||||
#define isc_mempool_destroy isc__mempool_destroy
|
||||
#define isc_mempool_associatelock isc__mempool_associatelock
|
||||
#define isc__mempool_get isc___mempool_get
|
||||
#define isc__mempool_put isc___mempool_put
|
||||
#define isc_mempool_setfreemax isc__mempool_setfreemax
|
||||
#define isc_mempool_getfreemax isc__mempool_getfreemax
|
||||
#define isc_mempool_getfreecount isc__mempool_getfreecount
|
||||
#define isc_mempool_setmaxalloc isc__mempool_setmaxalloc
|
||||
#define isc_mempool_getmaxalloc isc__mempool_getmaxalloc
|
||||
#define isc_mempool_getallocated isc__mempool_getallocated
|
||||
#define isc_mempool_setfillcount isc__mempool_setfillcount
|
||||
#define isc_mempool_getfillcount isc__mempool_getfillcount
|
||||
|
||||
#define isc_socket_create isc__socket_create
|
||||
#define isc_socket_dup isc__socket_dup
|
||||
#define isc_socket_attach isc__socket_attach
|
||||
#define isc_socket_detach isc__socket_detach
|
||||
#define isc_socketmgr_create isc__socketmgr_create
|
||||
#define isc_socketmgr_create2 isc__socketmgr_create2
|
||||
#define isc_socketmgr_destroy isc__socketmgr_destroy
|
||||
#define isc_socket_open isc__socket_open
|
||||
#define isc_socket_close isc__socket_close
|
||||
#define isc_socket_recvv isc__socket_recvv
|
||||
#define isc_socket_recv isc__socket_recv
|
||||
#define isc_socket_recv2 isc__socket_recv2
|
||||
#define isc_socket_send isc__socket_send
|
||||
#define isc_socket_sendto isc__socket_sendto
|
||||
#define isc_socket_sendv isc__socket_sendv
|
||||
#define isc_socket_sendtov isc__socket_sendtov
|
||||
#define isc_socket_sendto2 isc__socket_sendto2
|
||||
#define isc_socket_cleanunix isc__socket_cleanunix
|
||||
#define isc_socket_permunix isc__socket_permunix
|
||||
#define isc_socket_bind isc__socket_bind
|
||||
#define isc_socket_filter isc__socket_filter
|
||||
#define isc_socket_listen isc__socket_listen
|
||||
#define isc_socket_accept isc__socket_accept
|
||||
#define isc_socket_connect isc__socket_connect
|
||||
#define isc_socket_getfd isc__socket_getfd
|
||||
#define isc_socket_getname isc__socket_getname
|
||||
#define isc_socket_gettag isc__socket_gettag
|
||||
#define isc_socket_getpeername isc__socket_getpeername
|
||||
#define isc_socket_getsockname isc__socket_getsockname
|
||||
#define isc_socket_cancel isc__socket_cancel
|
||||
#define isc_socket_gettype isc__socket_gettype
|
||||
#define isc_socket_isbound isc__socket_isbound
|
||||
#define isc_socket_ipv6only isc__socket_ipv6only
|
||||
#define isc_socket_setname isc__socket_setname
|
||||
#define isc_socketmgr_getmaxsockets isc__socketmgr_getmaxsockets
|
||||
#define isc_socketmgr_setstats isc__socketmgr_setstats
|
||||
#define isc_socketmgr_setreserved isc__socketmgr_setreserved
|
||||
#define isc__socketmgr_maxudp isc___socketmgr_maxudp
|
||||
#define isc_socket_fdwatchcreate isc__socket_fdwatchcreate
|
||||
#define isc_socket_fdwatchpoke isc__socket_fdwatchpoke
|
||||
|
||||
#define isc_task_create isc__task_create
|
||||
#define isc_task_attach isc__task_attach
|
||||
#define isc_task_detach isc__task_detach
|
||||
/* #define isc_task_exiting isc__task_exiting XXXMPA */
|
||||
#define isc_task_send isc__task_send
|
||||
#define isc_task_sendanddetach isc__task_sendanddetach
|
||||
#define isc_task_purgerange isc__task_purgerange
|
||||
#define isc_task_purge isc__task_purge
|
||||
#define isc_task_purgeevent isc__task_purgeevent
|
||||
#define isc_task_unsendrange isc__task_unsendrange
|
||||
#define isc_task_unsend isc__task_unsend
|
||||
#define isc_task_onshutdown isc__task_onshutdown
|
||||
#define isc_task_shutdown isc__task_shutdown
|
||||
#define isc_task_destroy isc__task_destroy
|
||||
#define isc_task_setname isc__task_setname
|
||||
#define isc_task_getname isc__task_getname
|
||||
#define isc_task_gettag isc__task_gettag
|
||||
#define isc_task_getcurrenttime isc__task_getcurrenttime
|
||||
#define isc_taskmgr_create isc__taskmgr_create
|
||||
#define isc_taskmgr_setmode isc__taskmgr_setmode
|
||||
#define isc_taskmgr_mode isc__taskmgr_mode
|
||||
#define isc_taskmgr_destroy isc__taskmgr_destroy
|
||||
#define isc_task_beginexclusive isc__task_beginexclusive
|
||||
#define isc_task_endexclusive isc__task_endexclusive
|
||||
#define isc_task_setprivilege isc__task_setprivilege
|
||||
#define isc_task_privilege isc__task_privilege
|
||||
|
||||
#define isc_timer_create isc__timer_create
|
||||
#define isc_timer_reset isc__timer_reset
|
||||
#define isc_timer_gettype isc__timer_gettype
|
||||
#define isc_timer_touch isc__timer_touch
|
||||
#define isc_timer_attach isc__timer_attach
|
||||
#define isc_timer_detach isc__timer_detach
|
||||
#define isc_timermgr_create isc__timermgr_create
|
||||
#define isc_timermgr_poke isc__timermgr_poke
|
||||
#define isc_timermgr_destroy isc__timermgr_destroy
|
||||
|
||||
#endif /* BIND9 */
|
||||
|
||||
#endif /* ISCAPI_NAMESPACE_H */
|
||||
@@ -0,0 +1,373 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2007, 2008, 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2003 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: net.h,v 1.1.12.2 2016-01-14 05:18:03 jren Exp $ */
|
||||
|
||||
#ifndef ISC_NET_H
|
||||
#define ISC_NET_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file
|
||||
* \brief
|
||||
* Basic Networking Types
|
||||
*
|
||||
* This module is responsible for defining the following basic networking
|
||||
* types:
|
||||
*
|
||||
*\li struct in_addr
|
||||
*\li struct in6_addr
|
||||
*\li struct in6_pktinfo
|
||||
*\li struct sockaddr
|
||||
*\li struct sockaddr_in
|
||||
*\li struct sockaddr_in6
|
||||
*\li in_port_t
|
||||
*
|
||||
* It ensures that the AF_ and PF_ macros are defined.
|
||||
*
|
||||
* It declares ntoh[sl]() and hton[sl]().
|
||||
*
|
||||
* It declares inet_aton(), inet_ntop(), and inet_pton().
|
||||
*
|
||||
* It ensures that #INADDR_LOOPBACK, #INADDR_ANY, #IN6ADDR_ANY_INIT,
|
||||
* in6addr_any, and in6addr_loopback are available.
|
||||
*
|
||||
* It ensures that IN_MULTICAST() is available to check for multicast
|
||||
* addresses.
|
||||
*
|
||||
* MP:
|
||||
*\li No impact.
|
||||
*
|
||||
* Reliability:
|
||||
*\li No anticipated impact.
|
||||
*
|
||||
* Resources:
|
||||
*\li N/A.
|
||||
*
|
||||
* Security:
|
||||
*\li No anticipated impact.
|
||||
*
|
||||
* Standards:
|
||||
*\li BSD Socket API
|
||||
*\li RFC2553
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports.
|
||||
***/
|
||||
#include <isc/platform.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h> /* Contractual promise. */
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include <netinet/in.h> /* Contractual promise. */
|
||||
#include <arpa/inet.h> /* Contractual promise. */
|
||||
#ifdef ISC_PLATFORM_NEEDNETINETIN6H
|
||||
#include <netinet/in6.h> /* Required on UnixWare. */
|
||||
#endif
|
||||
#ifdef ISC_PLATFORM_NEEDNETINET6IN6H
|
||||
#include <netinet6/in6.h> /* Required on BSD/OS for in6_pktinfo. */
|
||||
#endif
|
||||
|
||||
#ifndef ISC_PLATFORM_HAVEIPV6
|
||||
#include <isc/ipv6.h> /* Contractual promise. */
|
||||
#endif
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVEINADDR6
|
||||
#define in6_addr in_addr6 /*%< Required for pre RFC2133 implementations. */
|
||||
#endif
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVEIPV6
|
||||
#ifndef IN6ADDR_ANY_INIT
|
||||
#ifdef s6_addr
|
||||
/*%
|
||||
* Required for some pre RFC2133 implementations.
|
||||
* IN6ADDR_ANY_INIT and IN6ADDR_LOOPBACK_INIT were added in
|
||||
* draft-ietf-ipngwg-bsd-api-04.txt or draft-ietf-ipngwg-bsd-api-05.txt.
|
||||
* If 's6_addr' is defined then assume that there is a union and three
|
||||
* levels otherwise assume two levels required.
|
||||
*/
|
||||
#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
|
||||
#else
|
||||
#define IN6ADDR_ANY_INIT { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef IN6ADDR_LOOPBACK_INIT
|
||||
#ifdef s6_addr
|
||||
/*% IPv6 address loopback init */
|
||||
#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
|
||||
#else
|
||||
#define IN6ADDR_LOOPBACK_INIT { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef IN6_IS_ADDR_V4MAPPED
|
||||
/*% Is IPv6 address V4 mapped? */
|
||||
#define IN6_IS_ADDR_V4MAPPED(x) \
|
||||
(memcmp((x)->s6_addr, in6addr_any.s6_addr, 10) == 0 && \
|
||||
(x)->s6_addr[10] == 0xff && (x)->s6_addr[11] == 0xff)
|
||||
#endif
|
||||
|
||||
#ifndef IN6_IS_ADDR_V4COMPAT
|
||||
/*% Is IPv6 address V4 compatible? */
|
||||
#define IN6_IS_ADDR_V4COMPAT(x) \
|
||||
(memcmp((x)->s6_addr, in6addr_any.s6_addr, 12) == 0 && \
|
||||
((x)->s6_addr[12] != 0 || (x)->s6_addr[13] != 0 || \
|
||||
(x)->s6_addr[14] != 0 || \
|
||||
((x)->s6_addr[15] != 0 && (x)->s6_addr[15] != 1)))
|
||||
#endif
|
||||
|
||||
#ifndef IN6_IS_ADDR_MULTICAST
|
||||
/*% Is IPv6 address multicast? */
|
||||
#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
|
||||
#endif
|
||||
|
||||
#ifndef IN6_IS_ADDR_LINKLOCAL
|
||||
/*% Is IPv6 address linklocal? */
|
||||
#define IN6_IS_ADDR_LINKLOCAL(a) \
|
||||
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
|
||||
#endif
|
||||
|
||||
#ifndef IN6_IS_ADDR_SITELOCAL
|
||||
/*% is IPv6 address sitelocal? */
|
||||
#define IN6_IS_ADDR_SITELOCAL(a) \
|
||||
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef IN6_IS_ADDR_LOOPBACK
|
||||
/*% is IPv6 address loopback? */
|
||||
#define IN6_IS_ADDR_LOOPBACK(x) \
|
||||
(memcmp((x)->s6_addr, in6addr_loopback.s6_addr, 16) == 0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef AF_INET6
|
||||
/*% IPv6 */
|
||||
#define AF_INET6 99
|
||||
#endif
|
||||
|
||||
#ifndef PF_INET6
|
||||
/*% IPv6 */
|
||||
#define PF_INET6 AF_INET6
|
||||
#endif
|
||||
|
||||
#ifndef INADDR_LOOPBACK
|
||||
/*% inaddr loopback */
|
||||
#define INADDR_LOOPBACK 0x7f000001UL
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
#ifndef ISC_PLATFORM_HAVEIN6PKTINFO
|
||||
/*% IPv6 packet info */
|
||||
struct in6_pktinfo {
|
||||
struct in6_addr ipi6_addr; /*%< src/dst IPv6 address */
|
||||
unsigned int ipi6_ifindex; /*%< send/recv interface index */
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(ISC_PLATFORM_NEEDIN6ADDRANY)
|
||||
extern const struct in6_addr isc_net_in6addrany;
|
||||
/*%
|
||||
* Cope with a missing in6addr_any and in6addr_loopback.
|
||||
*/
|
||||
#define in6addr_any isc_net_in6addrany
|
||||
#endif
|
||||
|
||||
#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK)
|
||||
extern const struct in6_addr isc_net_in6addrloop;
|
||||
#define in6addr_loopback isc_net_in6addrloop
|
||||
#endif
|
||||
|
||||
#ifdef ISC_PLATFORM_FIXIN6ISADDR
|
||||
#undef IN6_IS_ADDR_GEOGRAPHIC
|
||||
/*!
|
||||
* \brief
|
||||
* Fix UnixWare 7.1.1's broken IN6_IS_ADDR_* definitions.
|
||||
*/
|
||||
#define IN6_IS_ADDR_GEOGRAPHIC(a) (((a)->S6_un.S6_l[0] & 0xE0) == 0x80)
|
||||
#undef IN6_IS_ADDR_IPX
|
||||
#define IN6_IS_ADDR_IPX(a) (((a)->S6_un.S6_l[0] & 0xFE) == 0x04)
|
||||
#undef IN6_IS_ADDR_LINKLOCAL
|
||||
#define IN6_IS_ADDR_LINKLOCAL(a) (((a)->S6_un.S6_l[0] & 0xC0FF) == 0x80FE)
|
||||
#undef IN6_IS_ADDR_MULTICAST
|
||||
#define IN6_IS_ADDR_MULTICAST(a) (((a)->S6_un.S6_l[0] & 0xFF) == 0xFF)
|
||||
#undef IN6_IS_ADDR_NSAP
|
||||
#define IN6_IS_ADDR_NSAP(a) (((a)->S6_un.S6_l[0] & 0xFE) == 0x02)
|
||||
#undef IN6_IS_ADDR_PROVIDER
|
||||
#define IN6_IS_ADDR_PROVIDER(a) (((a)->S6_un.S6_l[0] & 0xE0) == 0x40)
|
||||
#undef IN6_IS_ADDR_SITELOCAL
|
||||
#define IN6_IS_ADDR_SITELOCAL(a) (((a)->S6_un.S6_l[0] & 0xC0FF) == 0xC0FE)
|
||||
#endif /* ISC_PLATFORM_FIXIN6ISADDR */
|
||||
|
||||
|
||||
/*%
|
||||
* Ensure type in_port_t is defined.
|
||||
*/
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDPORTT
|
||||
/*%
|
||||
* Ensure type in_port_t is defined.
|
||||
*/
|
||||
typedef isc_uint16_t in_port_t;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MSG_TRUNC
|
||||
/*%
|
||||
* If this system does not have MSG_TRUNC (as returned from recvmsg())
|
||||
* ISC_PLATFORM_RECVOVERFLOW will be defined. This will enable the MSG_TRUNC
|
||||
* faking code in socket.c.
|
||||
*/
|
||||
#define ISC_PLATFORM_RECVOVERFLOW
|
||||
#endif
|
||||
|
||||
/*% IP address. */
|
||||
#define ISC__IPADDR(x) ((isc_uint32_t)htonl((isc_uint32_t)(x)))
|
||||
|
||||
/*% Is IP address multicast? */
|
||||
#define ISC_IPADDR_ISMULTICAST(i) \
|
||||
(((isc_uint32_t)(i) & ISC__IPADDR(0xf0000000)) \
|
||||
== ISC__IPADDR(0xe0000000))
|
||||
|
||||
#define ISC_IPADDR_ISEXPERIMENTAL(i) \
|
||||
(((isc_uint32_t)(i) & ISC__IPADDR(0xf0000000)) \
|
||||
== ISC__IPADDR(0xf0000000))
|
||||
|
||||
/***
|
||||
*** Functions.
|
||||
***/
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
isc_net_probeipv4(void);
|
||||
/*%<
|
||||
* Check if the system's kernel supports IPv4.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li #ISC_R_SUCCESS IPv4 is supported.
|
||||
*\li #ISC_R_NOTFOUND IPv4 is not supported.
|
||||
*\li #ISC_R_DISABLED IPv4 is disabled.
|
||||
*\li #ISC_R_UNEXPECTED
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_net_probeipv6(void);
|
||||
/*%<
|
||||
* Check if the system's kernel supports IPv6.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li #ISC_R_SUCCESS IPv6 is supported.
|
||||
*\li #ISC_R_NOTFOUND IPv6 is not supported.
|
||||
*\li #ISC_R_DISABLED IPv6 is disabled.
|
||||
*\li #ISC_R_UNEXPECTED
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_net_probe_ipv6only(void);
|
||||
/*%<
|
||||
* Check if the system's kernel supports the IPV6_V6ONLY socket option.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li #ISC_R_SUCCESS the option is supported for both TCP and UDP.
|
||||
*\li #ISC_R_NOTFOUND IPv6 itself or the option is not supported.
|
||||
*\li #ISC_R_UNEXPECTED
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_net_probe_ipv6pktinfo(void);
|
||||
/*
|
||||
* Check if the system's kernel supports the IPV6_(RECV)PKTINFO socket option
|
||||
* for UDP sockets.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* \li #ISC_R_SUCCESS the option is supported.
|
||||
* \li #ISC_R_NOTFOUND IPv6 itself or the option is not supported.
|
||||
* \li #ISC_R_UNEXPECTED
|
||||
*/
|
||||
|
||||
void
|
||||
isc_net_disableipv4(void);
|
||||
|
||||
void
|
||||
isc_net_disableipv6(void);
|
||||
|
||||
void
|
||||
isc_net_enableipv4(void);
|
||||
|
||||
void
|
||||
isc_net_enableipv6(void);
|
||||
|
||||
isc_result_t
|
||||
isc_net_probeunix(void);
|
||||
/*
|
||||
* Returns whether UNIX domain sockets are supported.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_net_getudpportrange(int af, in_port_t *low, in_port_t *high);
|
||||
/*%<
|
||||
* Returns system's default range of ephemeral UDP ports, if defined.
|
||||
* If the range is not available or unknown, ISC_NET_PORTRANGELOW and
|
||||
* ISC_NET_PORTRANGEHIGH will be returned.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'low' and 'high' must be non NULL.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li *low and *high will be the ports specifying the low and high ends of
|
||||
* the range.
|
||||
*/
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDNTOP
|
||||
const char *
|
||||
isc_net_ntop(int af, const void *src, char *dst, size_t size);
|
||||
#define inet_ntop isc_net_ntop
|
||||
#endif
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDPTON
|
||||
int
|
||||
isc_net_pton(int af, const char *src, void *dst);
|
||||
#undef inet_pton
|
||||
#define inet_pton isc_net_pton
|
||||
#endif
|
||||
|
||||
int
|
||||
isc_net_aton(const char *cp, struct in_addr *addr);
|
||||
#undef inet_aton
|
||||
#define inet_aton isc_net_aton
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_NET_H */
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2002 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: netaddr.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_NETADDR_H
|
||||
#define ISC_NETADDR_H 1
|
||||
|
||||
/*! \file isc/netaddr.h */
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/net.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVESYSUNH
|
||||
#include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
struct isc_netaddr {
|
||||
unsigned int family;
|
||||
union {
|
||||
struct in_addr in;
|
||||
struct in6_addr in6;
|
||||
#ifdef ISC_PLATFORM_HAVESYSUNH
|
||||
char un[sizeof(((struct sockaddr_un *)0)->sun_path)];
|
||||
#endif
|
||||
} type;
|
||||
isc_uint32_t zone;
|
||||
};
|
||||
|
||||
isc_boolean_t
|
||||
isc_netaddr_equal(const isc_netaddr_t *a, const isc_netaddr_t *b);
|
||||
|
||||
/*%<
|
||||
* Compare network addresses 'a' and 'b'. Return #ISC_TRUE if
|
||||
* they are equal, #ISC_FALSE if not.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_netaddr_eqprefix(const isc_netaddr_t *a, const isc_netaddr_t *b,
|
||||
unsigned int prefixlen);
|
||||
/*%<
|
||||
* Compare the 'prefixlen' most significant bits of the network
|
||||
* addresses 'a' and 'b'. If 'b''s scope is zero then 'a''s scope is
|
||||
* ignored. Return #ISC_TRUE if they are equal, #ISC_FALSE if not.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_netaddr_masktoprefixlen(const isc_netaddr_t *s, unsigned int *lenp);
|
||||
/*%<
|
||||
* Convert a netmask in 's' into a prefix length in '*lenp'.
|
||||
* The mask should consist of zero or more '1' bits in the most
|
||||
* most significant part of the address, followed by '0' bits.
|
||||
* If this is not the case, #ISC_R_MASKNONCONTIG is returned.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_MASKNONCONTIG
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_netaddr_totext(const isc_netaddr_t *netaddr, isc_buffer_t *target);
|
||||
/*%<
|
||||
* Append a text representation of 'sockaddr' to the buffer 'target'.
|
||||
* The text is NOT null terminated. Handles IPv4 and IPv6 addresses.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_NOSPACE The text or the null termination did not fit.
|
||||
*\li #ISC_R_FAILURE Unspecified failure
|
||||
*/
|
||||
|
||||
void
|
||||
isc_netaddr_format(const isc_netaddr_t *na, char *array, unsigned int size);
|
||||
/*%<
|
||||
* Format a human-readable representation of the network address '*na'
|
||||
* into the character array 'array', which is of size 'size'.
|
||||
* The resulting string is guaranteed to be null-terminated.
|
||||
*/
|
||||
|
||||
#define ISC_NETADDR_FORMATSIZE \
|
||||
sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:XXX.XXX.XXX.XXX%SSSSSSSSSS")
|
||||
/*%<
|
||||
* Minimum size of array to pass to isc_netaddr_format().
|
||||
*/
|
||||
|
||||
void
|
||||
isc_netaddr_fromsockaddr(isc_netaddr_t *netaddr, const isc_sockaddr_t *source);
|
||||
|
||||
void
|
||||
isc_netaddr_fromin(isc_netaddr_t *netaddr, const struct in_addr *ina);
|
||||
|
||||
void
|
||||
isc_netaddr_fromin6(isc_netaddr_t *netaddr, const struct in6_addr *ina6);
|
||||
|
||||
isc_result_t
|
||||
isc_netaddr_frompath(isc_netaddr_t *netaddr, const char *path);
|
||||
|
||||
void
|
||||
isc_netaddr_setzone(isc_netaddr_t *netaddr, isc_uint32_t zone);
|
||||
|
||||
isc_uint32_t
|
||||
isc_netaddr_getzone(const isc_netaddr_t *netaddr);
|
||||
|
||||
void
|
||||
isc_netaddr_any(isc_netaddr_t *netaddr);
|
||||
/*%<
|
||||
* Return the IPv4 wildcard address.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_netaddr_any6(isc_netaddr_t *netaddr);
|
||||
/*%<
|
||||
* Return the IPv6 wildcard address.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_netaddr_ismulticast(isc_netaddr_t *na);
|
||||
/*%<
|
||||
* Returns ISC_TRUE if the address is a multicast address.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_netaddr_isexperimental(isc_netaddr_t *na);
|
||||
/*%<
|
||||
* Returns ISC_TRUE if the address is a experimental (CLASS E) address.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_netaddr_islinklocal(isc_netaddr_t *na);
|
||||
/*%<
|
||||
* Returns #ISC_TRUE if the address is a link local address.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_netaddr_issitelocal(isc_netaddr_t *na);
|
||||
/*%<
|
||||
* Returns #ISC_TRUE if the address is a site local address.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_netaddr_fromv4mapped(isc_netaddr_t *t, const isc_netaddr_t *s);
|
||||
/*%<
|
||||
* Convert an IPv6 v4mapped address into an IPv4 address.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_netaddr_prefixok(const isc_netaddr_t *na, unsigned int prefixlen);
|
||||
/*
|
||||
* Test whether the netaddr 'na' and 'prefixlen' are consistant.
|
||||
* e.g. prefixlen within range.
|
||||
* na does not have bits set which are not covered by the prefixlen.
|
||||
*
|
||||
* Returns:
|
||||
* ISC_R_SUCCESS
|
||||
* ISC_R_RANGE prefixlen out of range
|
||||
* ISC_R_NOTIMPLEMENTED unsupported family
|
||||
* ISC_R_FAILURE extra bits.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_NETADDR_H */
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: netdb.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_NETDB_H
|
||||
#define ISC_NETDB_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file
|
||||
* \brief
|
||||
* Portable netdb.h support.
|
||||
*
|
||||
* This module is responsible for defining the get<x>by<y> APIs.
|
||||
*
|
||||
* MP:
|
||||
*\li No impact.
|
||||
*
|
||||
* Reliability:
|
||||
*\li No anticipated impact.
|
||||
*
|
||||
* Resources:
|
||||
*\li N/A.
|
||||
*
|
||||
* Security:
|
||||
*\li No anticipated impact.
|
||||
*
|
||||
* Standards:
|
||||
*\li BSD API
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports.
|
||||
***/
|
||||
|
||||
#include <isc/net.h>
|
||||
|
||||
#include <netdb.h>
|
||||
|
||||
#endif /* ISC_NETDB_H */
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2002 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: netscope.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_NETSCOPE_H
|
||||
#define ISC_NETSCOPE_H 1
|
||||
|
||||
/*! \file isc/netscope.h */
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*%
|
||||
* Convert a string of an IPv6 scope zone to zone index. If the conversion
|
||||
* succeeds, 'zoneid' will store the index value.
|
||||
*
|
||||
* XXXJT: when a standard interface for this purpose is defined,
|
||||
* we should use it.
|
||||
*
|
||||
* Returns:
|
||||
* \li ISC_R_SUCCESS: conversion succeeds
|
||||
* \li ISC_R_FAILURE: conversion fails
|
||||
*/
|
||||
isc_result_t
|
||||
isc_netscope_pton(int af, char *scopename, void *addr, isc_uint32_t *zoneid);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_NETSCOPE_H */
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2007, 2008 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: offset.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_OFFSET_H
|
||||
#define ISC_OFFSET_H 1
|
||||
|
||||
/*! \file
|
||||
* \brief
|
||||
* File offsets are operating-system dependent.
|
||||
*/
|
||||
#include <limits.h> /* Required for CHAR_BIT. */
|
||||
#include <sys/types.h>
|
||||
#include <stddef.h> /* For Linux Standard Base. */
|
||||
|
||||
typedef off_t isc_offset_t;
|
||||
|
||||
/*%
|
||||
* POSIX says "Additionally, blkcnt_t and off_t are extended signed integral
|
||||
* types", so the maximum value is all 1s except for the high bit.
|
||||
* This definition is more complex than it really needs to be because it was
|
||||
* crafted to keep both the SunOS 5.6 and the HP/UX 11 compilers quiet about
|
||||
* integer overflow. For example, though this is equivalent to just left
|
||||
* shifting 1 to the high bit and then inverting the bits, the SunOS compiler
|
||||
* is unhappy about shifting a positive "1" to negative in a signed integer.
|
||||
*/
|
||||
#define ISC_OFFSET_MAXIMUM \
|
||||
(~(((off_t)-1 >> (sizeof(off_t) * CHAR_BIT - 1)) \
|
||||
<< (sizeof(off_t) * CHAR_BIT - 1)))
|
||||
|
||||
#endif /* ISC_OFFSET_H */
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: once.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_ONCE_H
|
||||
#define ISC_ONCE_H 1
|
||||
|
||||
#include <isc/result.h>
|
||||
|
||||
typedef isc_boolean_t isc_once_t;
|
||||
|
||||
#define ISC_ONCE_INIT ISC_FALSE
|
||||
|
||||
#define isc_once_do(op, f) \
|
||||
(!*(op) ? (f(), *(op) = ISC_TRUE, ISC_R_SUCCESS) : ISC_R_SUCCESS)
|
||||
|
||||
#endif /* ISC_ONCE_H */
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: ondestroy.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_ONDESTROY_H
|
||||
#define ISC_ONDESTROY_H 1
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*! \file isc/ondestroy.h
|
||||
* ondestroy handling.
|
||||
*
|
||||
* Any class ``X'' of objects that wants to send out notifications
|
||||
* on its destruction should declare a field of type isc_ondestroy_t
|
||||
* (call it 'ondest').
|
||||
*
|
||||
* \code
|
||||
* typedef struct {
|
||||
* ...
|
||||
* isc_ondestroy_t ondest;
|
||||
* ...
|
||||
* } X;
|
||||
* \endcode
|
||||
*
|
||||
* When an object ``A'' of type X is created
|
||||
* it must initialize the field ondest with a call to
|
||||
*
|
||||
* \code
|
||||
* isc_ondestroy_init(&A->ondest).
|
||||
* \endcode
|
||||
*
|
||||
* X should also provide a registration function for third-party
|
||||
* objects to call to register their interest in being told about
|
||||
* the destruction of a particular instance of X.
|
||||
*
|
||||
* \code
|
||||
* isc_result_t
|
||||
* X_ondestroy(X *instance, isc_task_t *task,
|
||||
* isc_event_t **eventp) {
|
||||
* return(isc_ondestroy_register(&instance->ondest, task,eventp));
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* Note: locking of the ondestory structure embedded inside of X, is
|
||||
* X's responsibility.
|
||||
*
|
||||
* When an instance of X is destroyed, a call to isc_ondestroy_notify()
|
||||
* sends the notifications:
|
||||
*
|
||||
* \code
|
||||
* X *instance;
|
||||
* isc_ondestroy_t ondest = instance->ondest;
|
||||
*
|
||||
* ... completely cleanup 'instance' here...
|
||||
*
|
||||
* isc_ondestroy_notify(&ondest, instance);
|
||||
* \endcode
|
||||
*
|
||||
*
|
||||
* see lib/dns/zone.c for an ifdef'd-out example.
|
||||
*/
|
||||
|
||||
struct isc_ondestroy {
|
||||
unsigned int magic;
|
||||
isc_eventlist_t events;
|
||||
};
|
||||
|
||||
void
|
||||
isc_ondestroy_init(isc_ondestroy_t *ondest);
|
||||
/*%<
|
||||
* Initialize the on ondest structure. *must* be called before first call
|
||||
* to isc_ondestroy_register().
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_ondestroy_register(isc_ondestroy_t *ondest, isc_task_t *task,
|
||||
isc_event_t **eventp);
|
||||
|
||||
/*%<
|
||||
* Stores task and *eventp away inside *ondest. Ownership of **event is
|
||||
* taken from the caller (and *eventp is set to NULL). The task is attached
|
||||
* to.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_ondestroy_notify(isc_ondestroy_t *ondest, void *sender);
|
||||
/*%<
|
||||
* Dispatches the event(s) to the task(s) that were given in
|
||||
* isc_ondestroy_register call(s) (done via calls to
|
||||
* isc_task_sendanddetach()). Before dispatch, the sender value of each
|
||||
* event structure is set to the value of the sender paramater. The
|
||||
* internal structures of the ondest parameter are cleaned out, so no other
|
||||
* cleanup is needed.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_ONDESTROY_H */
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: os.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_OS_H
|
||||
#define ISC_OS_H 1
|
||||
|
||||
/*! \file isc/os.h */
|
||||
|
||||
#include <isc/lang.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
unsigned int
|
||||
isc_os_ncpus(void);
|
||||
/*%<
|
||||
* Return the number of CPUs available on the system, or 1 if this cannot
|
||||
* be determined.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_OS_H */
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2001, 2002 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: parseint.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_PARSEINT_H
|
||||
#define ISC_PARSEINT_H 1
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/*! \file isc/parseint.h
|
||||
* \brief Parse integers, in a saner way than atoi() or strtoul() do.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
isc_parse_uint32(isc_uint32_t *uip, const char *string, int base);
|
||||
|
||||
isc_result_t
|
||||
isc_parse_uint16(isc_uint16_t *uip, const char *string, int base);
|
||||
|
||||
isc_result_t
|
||||
isc_parse_uint8(isc_uint8_t *uip, const char *string, int base);
|
||||
/*%<
|
||||
* Parse the null-terminated string 'string' containing a base 'base'
|
||||
* integer, storing the result in '*uip'.
|
||||
* The base is interpreted
|
||||
* as in strtoul(). Unlike strtoul(), leading whitespace, minus or
|
||||
* plus signs are not accepted, and all errors (including overflow)
|
||||
* are reported uniformly through the return value.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'string' points to a null-terminated string
|
||||
*\li 0 <= 'base' <= 36
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_BADNUMBER The string is not numeric (in the given base)
|
||||
*\li #ISC_R_RANGE The number is not representable as the requested type.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_PARSEINT_H */
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 1999-2001 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: platform.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_PLATFORM_H
|
||||
#define ISC_PLATFORM_H 1
|
||||
|
||||
#define ISC_PLATFORM_NORETURN_PRE
|
||||
#define ISC_PLATFORM_NORETURN_POST
|
||||
|
||||
|
||||
#ifndef ISC_PLATFORM_USEDECLSPEC
|
||||
#define LIBISC_EXTERNAL_DATA
|
||||
#define LIBDNS_EXTERNAL_DATA
|
||||
#define LIBISCCC_EXTERNAL_DATA
|
||||
#define LIBISCCFG_EXTERNAL_DATA
|
||||
#define LIBBIND9_EXTERNAL_DATA
|
||||
#endif /* ISC_PLATFORM_USEDECLSPEC */
|
||||
|
||||
/*
|
||||
* Tell emacs to use C mode for this file.
|
||||
*
|
||||
* Local Variables:
|
||||
* mode: c
|
||||
* End:
|
||||
*/
|
||||
|
||||
#endif /* ISC_PLATFORM_H */
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (C) 2008, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: portset.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
/*! \file isc/portset.h
|
||||
* \brief Transport Protocol Port Manipulation Module
|
||||
*
|
||||
* This module provides simple utilities to handle a set of transport protocol
|
||||
* (UDP or TCP) port numbers, e.g., for creating an ACL list. An isc_portset_t
|
||||
* object is an opaque instance of a port set, for which the user can add or
|
||||
* remove a specific port or a range of consecutive ports. This object is
|
||||
* expected to be used as a temporary work space only, and does not protect
|
||||
* simultaneous access from multiple threads. Therefore it must not be stored
|
||||
* in a place that can be accessed from multiple threads.
|
||||
*/
|
||||
|
||||
#ifndef ISC_PORTSET_H
|
||||
#define ISC_PORTSET_H 1
|
||||
|
||||
/***
|
||||
*** Imports
|
||||
***/
|
||||
|
||||
#include <isc/net.h>
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
isc_portset_create(isc_mem_t *mctx, isc_portset_t **portsetp);
|
||||
/*%<
|
||||
* Create a port set and initialize it as an empty set.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'mctx' to be valid.
|
||||
*\li 'portsetp' to be non NULL and '*portsetp' to be NULL;
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_NOMEMORY
|
||||
*/
|
||||
|
||||
void
|
||||
isc_portset_destroy(isc_mem_t *mctx, isc_portset_t **portsetp);
|
||||
/*%<
|
||||
* Destroy a port set.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'mctx' to be valid and must be the same context given when the port set
|
||||
* was created.
|
||||
*\li '*portsetp' to be a valid set.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_portset_isset(isc_portset_t *portset, in_port_t port);
|
||||
/*%<
|
||||
* Test whether the given port is stored in the portset.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'portset' to be a valid set.
|
||||
*
|
||||
* Returns
|
||||
* \li #ISC_TRUE if the port is found, ISC_FALSE otherwise.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_portset_nports(isc_portset_t *portset);
|
||||
/*%<
|
||||
* Provides the number of ports stored in the given portset.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'portset' to be a valid set.
|
||||
*
|
||||
* Returns
|
||||
* \li the number of ports stored in portset.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_portset_add(isc_portset_t *portset, in_port_t port);
|
||||
/*%<
|
||||
* Add the given port to the portset. The port may or may not be stored in
|
||||
* the portset.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'portlist' to be valid.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_portset_remove(isc_portset_t *portset, in_port_t port);
|
||||
/*%<
|
||||
* Remove the given port to the portset. The port may or may not be stored in
|
||||
* the portset.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'portlist' to be valid.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_portset_addrange(isc_portset_t *portset, in_port_t port_lo,
|
||||
in_port_t port_hi);
|
||||
/*%<
|
||||
* Add a subset of [port_lo, port_hi] (inclusive) to the portset. Ports in the
|
||||
* subset may or may not be stored in portset.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'portlist' to be valid.
|
||||
*\li port_lo <= port_hi
|
||||
*/
|
||||
|
||||
void
|
||||
isc_portset_removerange(isc_portset_t *portset, in_port_t port_lo,
|
||||
in_port_t port_hi);
|
||||
/*%<
|
||||
* Subtract a subset of [port_lo, port_hi] (inclusive) from the portset. Ports
|
||||
* in the subset may or may not be stored in portset.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'portlist' to be valid.
|
||||
*\li port_lo <= port_hi
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_PORTSET_H */
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001, 2003 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: print.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_PRINT_H
|
||||
#define ISC_PRINT_H 1
|
||||
|
||||
/*! \file isc/print.h */
|
||||
|
||||
/***
|
||||
*** Imports
|
||||
***/
|
||||
|
||||
#include <isc/formatcheck.h> /* Required for ISC_FORMAT_PRINTF() macro. */
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
|
||||
/*!
|
||||
* This block allows lib/isc/print.c to be cleanly compiled even if
|
||||
* the platform does not need it. The standard Makefile will still
|
||||
* not compile print.c or archive print.o, so this is just to make test
|
||||
* compilation ("make print.o") easier.
|
||||
*/
|
||||
#if !defined(ISC_PLATFORM_NEEDVSNPRINTF) && defined(ISC__PRINT_SOURCE)
|
||||
#define ISC_PLATFORM_NEEDVSNPRINTF
|
||||
#endif
|
||||
|
||||
#if !defined(ISC_PLATFORM_NEEDSPRINTF) && defined(ISC__PRINT_SOURCE)
|
||||
#define ISC_PLATFORM_NEEDSPRINTF
|
||||
#endif
|
||||
|
||||
/***
|
||||
*** Macros
|
||||
***/
|
||||
#define ISC_PRINT_QUADFORMAT ISC_PLATFORM_QUADFORMAT
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDVSNPRINTF
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
#ifdef ISC_PLATFORM_NEEDSPRINTF
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDVSNPRINTF
|
||||
int
|
||||
isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap)
|
||||
ISC_FORMAT_PRINTF(3, 0);
|
||||
#define vsnprintf isc_print_vsnprintf
|
||||
|
||||
int
|
||||
isc_print_snprintf(char *str, size_t size, const char *format, ...)
|
||||
ISC_FORMAT_PRINTF(3, 4);
|
||||
#define snprintf isc_print_snprintf
|
||||
#endif /* ISC_PLATFORM_NEEDVSNPRINTF */
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDSPRINTF
|
||||
int
|
||||
isc_print_sprintf(char *str, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);
|
||||
#define sprintf isc_print_sprintf
|
||||
#endif
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_PRINT_H */
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (C) 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: queue.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
/*
|
||||
* This is a generic implementation of a two-lock concurrent queue.
|
||||
* There are built-in mutex locks for the head and tail of the queue,
|
||||
* allowing elements to be safely added and removed at the same time.
|
||||
*/
|
||||
|
||||
#ifndef ISC_QUEUE_H
|
||||
#define ISC_QUEUE_H 1
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/boolean.h>
|
||||
#include <isc/mutex.h>
|
||||
|
||||
#ifdef ISC_QUEUE_CHECKINIT
|
||||
#define ISC_QLINK_INSIST(x) ISC_INSIST(x)
|
||||
#else
|
||||
#define ISC_QLINK_INSIST(x) (void)0
|
||||
#endif
|
||||
|
||||
#define ISC_QLINK(type) struct { void *next; isc_boolean_t linked; }
|
||||
#define ISC_QLINK_INIT(elt, link) \
|
||||
do { \
|
||||
(elt)->link.next = (void *)(-1); \
|
||||
(elt)->link.linked = ISC_FALSE; \
|
||||
} while (0)
|
||||
#define ISC_QLINK_LINKED(elt, link) ((elt)->link.linked)
|
||||
|
||||
#define ISC_QUEUE(type) struct { \
|
||||
type headnode; \
|
||||
type *head, *tail; \
|
||||
isc_mutex_t headlock, taillock; \
|
||||
}
|
||||
|
||||
#define ISC_QUEUE_INIT(queue, link) \
|
||||
do { \
|
||||
isc_mutex_init(&(queue).headlock); \
|
||||
isc_mutex_init(&(queue).taillock); \
|
||||
(queue).head = (void *) &((queue).headnode); \
|
||||
(queue).tail = (void *) &((queue).headnode); \
|
||||
ISC_QLINK_INIT((queue).head, link); \
|
||||
} while (0)
|
||||
|
||||
#define ISC_QUEUE_EMPTY(queue) ISC_TF((queue).head == (queue).tail)
|
||||
|
||||
#define ISC_QUEUE_DESTROY(queue) \
|
||||
do { \
|
||||
ISC_QLINK_INSIST(ISC_QUEUE_EMPTY(queue)); \
|
||||
isc_mutex_destroy(&(queue).headlock); \
|
||||
isc_mutex_destroy(&(queue).taillock); \
|
||||
} while (0)
|
||||
|
||||
#define ISC_QUEUE_PUSH(queue, elt, link) \
|
||||
do { \
|
||||
ISC_QLINK_INSIST(!ISC_QLINK_LINKED(elt, link)); \
|
||||
(elt)->link.next = (void *)(-1); \
|
||||
LOCK(&(queue).taillock); \
|
||||
(queue).tail->link.next = elt; \
|
||||
(queue).tail = elt; \
|
||||
UNLOCK(&(queue).taillock); \
|
||||
(elt)->link.linked = ISC_TRUE; \
|
||||
} while (0)
|
||||
|
||||
#define ISC_QUEUE_POP(queue, link, ret) \
|
||||
do { \
|
||||
LOCK(&(queue).headlock); \
|
||||
ret = (queue).head->link.next; \
|
||||
if (ret == (void *)(-1)) { \
|
||||
UNLOCK(&(queue).headlock); \
|
||||
ret = NULL; \
|
||||
} else { \
|
||||
(queue).head->link.next = ret->link.next; \
|
||||
if (ret->link.next == (void *)(-1)) { \
|
||||
LOCK(&(queue).taillock); \
|
||||
(queue).tail = (queue).head; \
|
||||
UNLOCK(&(queue).taillock); \
|
||||
} \
|
||||
UNLOCK(&(queue).headlock); \
|
||||
ret->link.next = (void *)(-1); \
|
||||
ret->link.linked = ISC_FALSE; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif /* ISC_QUEUE_H */
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: quota.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_QUOTA_H
|
||||
#define ISC_QUOTA_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/quota.h
|
||||
*
|
||||
* \brief The isc_quota_t object is a simple helper object for implementing
|
||||
* quotas on things like the number of simultaneous connections to
|
||||
* a server. It keeps track of the amount of quota in use, and
|
||||
* encapsulates the locking necessary to allow multiple tasks to
|
||||
* share a quota.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports.
|
||||
***/
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/*****
|
||||
***** Types.
|
||||
*****/
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*% isc_quota structure */
|
||||
struct isc_quota {
|
||||
isc_mutex_t lock; /*%< Locked by lock. */
|
||||
int max;
|
||||
int used;
|
||||
int soft;
|
||||
};
|
||||
|
||||
isc_result_t
|
||||
isc_quota_init(isc_quota_t *quota, int max);
|
||||
/*%<
|
||||
* Initialize a quota object.
|
||||
*
|
||||
* Returns:
|
||||
* ISC_R_SUCCESS
|
||||
* Other error Lock creation failed.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_quota_destroy(isc_quota_t *quota);
|
||||
/*%<
|
||||
* Destroy a quota object.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_quota_soft(isc_quota_t *quota, int soft);
|
||||
/*%<
|
||||
* Set a soft quota.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_quota_max(isc_quota_t *quota, int max);
|
||||
/*%<
|
||||
* Re-set a maximum quota.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_quota_reserve(isc_quota_t *quota);
|
||||
/*%<
|
||||
* Attempt to reserve one unit of 'quota'.
|
||||
*
|
||||
* Returns:
|
||||
* \li #ISC_R_SUCCESS Success
|
||||
* \li #ISC_R_SOFTQUOTA Success soft quota reached
|
||||
* \li #ISC_R_QUOTA Quota is full
|
||||
*/
|
||||
|
||||
void
|
||||
isc_quota_release(isc_quota_t *quota);
|
||||
/*%<
|
||||
* Release one unit of quota.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_quota_attach(isc_quota_t *quota, isc_quota_t **p);
|
||||
/*%<
|
||||
* Like isc_quota_reserve, and also attaches '*p' to the
|
||||
* quota if successful (ISC_R_SUCCESS or ISC_R_SOFTQUOTA).
|
||||
*/
|
||||
|
||||
void
|
||||
isc_quota_detach(isc_quota_t **p);
|
||||
/*%<
|
||||
* Like isc_quota_release, and also detaches '*p' from the
|
||||
* quota.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_QUOTA_H */
|
||||
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* Copyright (C) 2007, 2008 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: radix.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
/*
|
||||
* This source was adapted from MRT's RCS Ids:
|
||||
* Id: radix.h,v 1.6 1999/08/03 03:32:53 masaki Exp
|
||||
* Id: mrt.h,v 1.57.2.6 1999/12/28 23:41:27 labovit Exp
|
||||
* Id: defs.h,v 1.5.2.2 2000/01/15 14:19:16 masaki Exp
|
||||
*/
|
||||
|
||||
#include <isc/magic.h>
|
||||
#include <isc/types.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/net.h>
|
||||
#include <isc/refcount.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifndef _RADIX_H
|
||||
#define _RADIX_H
|
||||
|
||||
#define NETADDR_TO_PREFIX_T(na,pt,bits) \
|
||||
do { \
|
||||
memset(&(pt), 0, sizeof(pt)); \
|
||||
if((na) != NULL) { \
|
||||
(pt).family = (na)->family; \
|
||||
(pt).bitlen = (bits); \
|
||||
if ((pt).family == AF_INET6) { \
|
||||
memcpy(&(pt).add.sin6, &(na)->type.in6, \
|
||||
((bits)+7)/8); \
|
||||
} else \
|
||||
memcpy(&(pt).add.sin, &(na)->type.in, \
|
||||
((bits)+7)/8); \
|
||||
} else { \
|
||||
(pt).family = AF_UNSPEC; \
|
||||
(pt).bitlen = 0; \
|
||||
} \
|
||||
isc_refcount_init(&(pt).refcount, 0); \
|
||||
} while(0)
|
||||
|
||||
typedef struct isc_prefix {
|
||||
unsigned int family; /* AF_INET | AF_INET6, or AF_UNSPEC for "any" */
|
||||
unsigned int bitlen; /* 0 for "any" */
|
||||
isc_refcount_t refcount;
|
||||
union {
|
||||
struct in_addr sin;
|
||||
struct in6_addr sin6;
|
||||
} add;
|
||||
} isc_prefix_t;
|
||||
|
||||
typedef void (*isc_radix_destroyfunc_t)(void *);
|
||||
typedef void (*isc_radix_processfunc_t)(isc_prefix_t *, void **);
|
||||
|
||||
#define isc_prefix_tochar(prefix) ((char *)&(prefix)->add.sin)
|
||||
#define isc_prefix_touchar(prefix) ((u_char *)&(prefix)->add.sin)
|
||||
|
||||
#define BIT_TEST(f, b) ((f) & (b))
|
||||
|
||||
/*
|
||||
* We need "first match" when we search the radix tree to preserve
|
||||
* compatibility with the existing ACL implementation. Radix trees
|
||||
* naturally lend themselves to "best match". In order to get "first match"
|
||||
* behavior, we keep track of the order in which entries are added to the
|
||||
* tree--and when a search is made, we find all matching entries, and
|
||||
* return the one that was added first.
|
||||
*
|
||||
* An IPv4 prefix and an IPv6 prefix may share a radix tree node if they
|
||||
* have the same length and bit pattern (e.g., 127/8 and 7f::/8). To
|
||||
* disambiguate between them, node_num and data are two-element arrays;
|
||||
* node_num[0] and data[0] are used for IPv4 addresses, node_num[1]
|
||||
* and data[1] for IPv6 addresses. The only exception is a prefix of
|
||||
* 0/0 (aka "any" or "none"), which is always stored as IPv4 but matches
|
||||
* IPv6 addresses too.
|
||||
*/
|
||||
|
||||
#define ISC_IS6(family) ((family) == AF_INET6 ? 1 : 0)
|
||||
typedef struct isc_radix_node {
|
||||
isc_uint32_t bit; /* bit length of the prefix */
|
||||
isc_prefix_t *prefix; /* who we are in radix tree */
|
||||
struct isc_radix_node *l, *r; /* left and right children */
|
||||
struct isc_radix_node *parent; /* may be used */
|
||||
void *data[2]; /* pointers to IPv4 and IPV6 data */
|
||||
int node_num[2]; /* which node this was in the tree,
|
||||
or -1 for glue nodes */
|
||||
} isc_radix_node_t;
|
||||
|
||||
#define RADIX_TREE_MAGIC ISC_MAGIC('R','d','x','T');
|
||||
#define RADIX_TREE_VALID(a) ISC_MAGIC_VALID(a, RADIX_TREE_MAGIC);
|
||||
|
||||
typedef struct isc_radix_tree {
|
||||
unsigned int magic;
|
||||
isc_mem_t *mctx;
|
||||
isc_radix_node_t *head;
|
||||
isc_uint32_t maxbits; /* for IP, 32 bit addresses */
|
||||
int num_active_node; /* for debugging purposes */
|
||||
int num_added_node; /* total number of nodes */
|
||||
} isc_radix_tree_t;
|
||||
|
||||
isc_result_t
|
||||
isc_radix_search(isc_radix_tree_t *radix, isc_radix_node_t **target,
|
||||
isc_prefix_t *prefix);
|
||||
/*%<
|
||||
* Search 'radix' for the best match to 'prefix'.
|
||||
* Return the node found in '*target'.
|
||||
*
|
||||
* Requires:
|
||||
* \li 'radix' to be valid.
|
||||
* \li 'target' is not NULL and "*target" is NULL.
|
||||
* \li 'prefix' to be valid.
|
||||
*
|
||||
* Returns:
|
||||
* \li ISC_R_NOTFOUND
|
||||
* \li ISC_R_SUCCESS
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_radix_insert(isc_radix_tree_t *radix, isc_radix_node_t **target,
|
||||
isc_radix_node_t *source, isc_prefix_t *prefix);
|
||||
/*%<
|
||||
* Insert 'source' or 'prefix' into the radix tree 'radix'.
|
||||
* Return the node added in 'target'.
|
||||
*
|
||||
* Requires:
|
||||
* \li 'radix' to be valid.
|
||||
* \li 'target' is not NULL and "*target" is NULL.
|
||||
* \li 'prefix' to be valid or 'source' to be non NULL and contain
|
||||
* a valid prefix.
|
||||
*
|
||||
* Returns:
|
||||
* \li ISC_R_NOMEMORY
|
||||
* \li ISC_R_SUCCESS
|
||||
*/
|
||||
|
||||
void
|
||||
isc_radix_remove(isc_radix_tree_t *radix, isc_radix_node_t *node);
|
||||
/*%<
|
||||
* Remove the node 'node' from the radix tree 'radix'.
|
||||
*
|
||||
* Requires:
|
||||
* \li 'radix' to be valid.
|
||||
* \li 'node' to be valid.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_radix_create(isc_mem_t *mctx, isc_radix_tree_t **target, int maxbits);
|
||||
/*%<
|
||||
* Create a radix tree with a maximum depth of 'maxbits';
|
||||
*
|
||||
* Requires:
|
||||
* \li 'mctx' to be valid.
|
||||
* \li 'target' to be non NULL and '*target' to be NULL.
|
||||
* \li 'maxbits' to be less than or equal to RADIX_MAXBITS.
|
||||
*
|
||||
* Returns:
|
||||
* \li ISC_R_NOMEMORY
|
||||
* \li ISC_R_SUCCESS
|
||||
*/
|
||||
|
||||
void
|
||||
isc_radix_destroy(isc_radix_tree_t *radix, isc_radix_destroyfunc_t func);
|
||||
/*%<
|
||||
* Destroy a radix tree optionally calling 'func' to clean up node data.
|
||||
*
|
||||
* Requires:
|
||||
* \li 'radix' to be valid.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_radix_process(isc_radix_tree_t *radix, isc_radix_processfunc_t func);
|
||||
/*%<
|
||||
* Walk a radix tree calling 'func' to process node data.
|
||||
*
|
||||
* Requires:
|
||||
* \li 'radix' to be valid.
|
||||
* \li 'func' to point to a function.
|
||||
*/
|
||||
|
||||
#define RADIX_MAXBITS 128
|
||||
#define RADIX_NBIT(x) (0x80 >> ((x) & 0x7f))
|
||||
#define RADIX_NBYTE(x) ((x) >> 3)
|
||||
|
||||
#define RADIX_DATA_GET(node, type) (type *)((node)->data)
|
||||
#define RADIX_DATA_SET(node, value) ((node)->data = (void *)(value))
|
||||
|
||||
#define RADIX_WALK(Xhead, Xnode) \
|
||||
do { \
|
||||
isc_radix_node_t *Xstack[RADIX_MAXBITS+1]; \
|
||||
isc_radix_node_t **Xsp = Xstack; \
|
||||
isc_radix_node_t *Xrn = (Xhead); \
|
||||
while ((Xnode = Xrn)) { \
|
||||
if (Xnode->prefix)
|
||||
|
||||
#define RADIX_WALK_ALL(Xhead, Xnode) \
|
||||
do { \
|
||||
isc_radix_node_t *Xstack[RADIX_MAXBITS+1]; \
|
||||
isc_radix_node_t **Xsp = Xstack; \
|
||||
isc_radix_node_t *Xrn = (Xhead); \
|
||||
while ((Xnode = Xrn)) { \
|
||||
if (1)
|
||||
|
||||
#define RADIX_WALK_BREAK { \
|
||||
if (Xsp != Xstack) { \
|
||||
Xrn = *(--Xsp); \
|
||||
} else { \
|
||||
Xrn = (radix_node_t *) 0; \
|
||||
} \
|
||||
continue; }
|
||||
|
||||
#define RADIX_WALK_END \
|
||||
if (Xrn->l) { \
|
||||
if (Xrn->r) { \
|
||||
*Xsp++ = Xrn->r; \
|
||||
} \
|
||||
Xrn = Xrn->l; \
|
||||
} else if (Xrn->r) { \
|
||||
Xrn = Xrn->r; \
|
||||
} else if (Xsp != Xstack) { \
|
||||
Xrn = *(--Xsp); \
|
||||
} else { \
|
||||
Xrn = (isc_radix_node_t *) 0; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif /* _RADIX_H */
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: random.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_RANDOM_H
|
||||
#define ISC_RANDOM_H 1
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/*! \file isc/random.h
|
||||
* \brief Implements a random state pool which will let the caller return a
|
||||
* series of possibly non-reproducible random values.
|
||||
*
|
||||
* Note that the
|
||||
* strength of these numbers is not all that high, and should not be
|
||||
* used in cryptography functions. It is useful for jittering values
|
||||
* a bit here and there, such as timeouts, etc.
|
||||
*/
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
void
|
||||
isc_random_seed(isc_uint32_t seed);
|
||||
/*%<
|
||||
* Set the initial seed of the random state.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_random_get(isc_uint32_t *val);
|
||||
/*%<
|
||||
* Get a random value.
|
||||
*
|
||||
* Requires:
|
||||
* val != NULL.
|
||||
*/
|
||||
|
||||
isc_uint32_t
|
||||
isc_random_jitter(isc_uint32_t max, isc_uint32_t jitter);
|
||||
/*%<
|
||||
* Get a random value between (max - jitter) and (max).
|
||||
* This is useful for jittering timer values.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_RANDOM_H */
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2002 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: ratelimiter.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_RATELIMITER_H
|
||||
#define ISC_RATELIMITER_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/ratelimiter.h
|
||||
* \brief A rate limiter is a mechanism for dispatching events at a limited
|
||||
* rate. This is intended to be used when sending zone maintenance
|
||||
* SOA queries, NOTIFY messages, etc.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports.
|
||||
***/
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*****
|
||||
***** Functions.
|
||||
*****/
|
||||
|
||||
isc_result_t
|
||||
isc_ratelimiter_create(isc_mem_t *mctx, isc_timermgr_t *timermgr,
|
||||
isc_task_t *task, isc_ratelimiter_t **ratelimiterp);
|
||||
/*%<
|
||||
* Create a rate limiter. The execution interval is initially undefined.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_ratelimiter_setinterval(isc_ratelimiter_t *rl, isc_interval_t *interval);
|
||||
/*!<
|
||||
* Set the minimum interval between event executions.
|
||||
* The interval value is copied, so the caller need not preserve it.
|
||||
*
|
||||
* Requires:
|
||||
* '*interval' is a nonzero interval.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_ratelimiter_setpertic(isc_ratelimiter_t *rl, isc_uint32_t perint);
|
||||
/*%<
|
||||
* Set the number of events processed per interval timer tick.
|
||||
* If 'perint' is zero it is treated as 1.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_ratelimiter_enqueue(isc_ratelimiter_t *rl, isc_task_t *task,
|
||||
isc_event_t **eventp);
|
||||
/*%<
|
||||
* Queue an event for rate-limited execution.
|
||||
*
|
||||
* This is similar
|
||||
* to doing an isc_task_send() to the 'task', except that the
|
||||
* execution may be delayed to achieve the desired rate of
|
||||
* execution.
|
||||
*
|
||||
* '(*eventp)->ev_sender' is used to hold the task. The caller
|
||||
* must ensure that the task exists until the event is delivered.
|
||||
*
|
||||
* Requires:
|
||||
*\li An interval has been set by calling
|
||||
* isc_ratelimiter_setinterval().
|
||||
*
|
||||
*\li 'task' to be non NULL.
|
||||
*\li '(*eventp)->ev_sender' to be NULL.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_ratelimiter_shutdown(isc_ratelimiter_t *ratelimiter);
|
||||
/*%<
|
||||
* Shut down a rate limiter.
|
||||
*
|
||||
* Ensures:
|
||||
*\li All events that have not yet been
|
||||
* dispatched to the task are dispatched immediately with
|
||||
* the #ISC_EVENTATTR_CANCELED bit set in ev_attributes.
|
||||
*
|
||||
*\li Further attempts to enqueue events will fail with
|
||||
* #ISC_R_SHUTTINGDOWN.
|
||||
*
|
||||
*\li The rate limiter is no longer attached to its task.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_ratelimiter_attach(isc_ratelimiter_t *source, isc_ratelimiter_t **target);
|
||||
/*%<
|
||||
* Attach to a rate limiter.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_ratelimiter_detach(isc_ratelimiter_t **ratelimiterp);
|
||||
/*%<
|
||||
* Detach from a rate limiter.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_ratelimiter_stall(isc_ratelimiter_t *rl);
|
||||
/*%<
|
||||
* Stall event processing.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_ratelimiter_release(isc_ratelimiter_t *rl);
|
||||
/*%<
|
||||
* Release a stalled rate limiter.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_RATELIMITER_H */
|
||||
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2001, 2003 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: refcount.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_REFCOUNT_H
|
||||
#define ISC_REFCOUNT_H 1
|
||||
|
||||
#include <isc/atomic.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/mutex.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/types.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
/*! \file isc/refcount.h
|
||||
* \brief Implements a locked reference counter.
|
||||
*
|
||||
* These functions may actually be
|
||||
* implemented using macros, and implementations of these macros are below.
|
||||
* The isc_refcount_t type should not be accessed directly, as its contents
|
||||
* depend on the implementation.
|
||||
*/
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
|
||||
/*
|
||||
* isc_result_t
|
||||
* isc_refcount_init(isc_refcount_t *ref, unsigned int n);
|
||||
*
|
||||
* Initialize the reference counter. There will be 'n' initial references.
|
||||
*
|
||||
* Requires:
|
||||
* ref != NULL
|
||||
*/
|
||||
|
||||
/*
|
||||
* void
|
||||
* isc_refcount_destroy(isc_refcount_t *ref);
|
||||
*
|
||||
* Destroys a reference counter.
|
||||
*
|
||||
* Requires:
|
||||
* ref != NULL
|
||||
* The number of references is 0.
|
||||
*/
|
||||
|
||||
/*
|
||||
* void
|
||||
* isc_refcount_increment(isc_refcount_t *ref, unsigned int *targetp);
|
||||
* isc_refcount_increment0(isc_refcount_t *ref, unsigned int *targetp);
|
||||
*
|
||||
* Increments the reference count, returning the new value in targetp if it's
|
||||
* not NULL. The reference counter typically begins with the initial counter
|
||||
* of 1, and will be destroyed once the counter reaches 0. Thus,
|
||||
* isc_refcount_increment() additionally requires the previous counter be
|
||||
* larger than 0 so that an error which violates the usage can be easily
|
||||
* caught. isc_refcount_increment0() does not have this restriction.
|
||||
*
|
||||
* Requires:
|
||||
* ref != NULL.
|
||||
*/
|
||||
|
||||
/*
|
||||
* void
|
||||
* isc_refcount_decrement(isc_refcount_t *ref, unsigned int *targetp);
|
||||
*
|
||||
* Decrements the reference count, returning the new value in targetp if it's
|
||||
* not NULL.
|
||||
*
|
||||
* Requires:
|
||||
* ref != NULL.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Sample implementations
|
||||
*/
|
||||
#ifdef ISC_PLATFORM_USETHREADS
|
||||
#ifdef ISC_PLATFORM_HAVEXADD
|
||||
|
||||
#define ISC_REFCOUNT_HAVEATOMIC 1
|
||||
|
||||
typedef struct isc_refcount {
|
||||
isc_int32_t refs;
|
||||
} isc_refcount_t;
|
||||
|
||||
#define isc_refcount_destroy(rp) REQUIRE((rp)->refs == 0)
|
||||
#define isc_refcount_current(rp) ((unsigned int)((rp)->refs))
|
||||
|
||||
#define isc_refcount_increment0(rp, tp) \
|
||||
do { \
|
||||
unsigned int *_tmp = (unsigned int *)(tp); \
|
||||
isc_int32_t prev; \
|
||||
prev = isc_atomic_xadd(&(rp)->refs, 1); \
|
||||
if (_tmp != NULL) \
|
||||
*_tmp = prev + 1; \
|
||||
} while (0)
|
||||
|
||||
#define isc_refcount_increment(rp, tp) \
|
||||
do { \
|
||||
unsigned int *_tmp = (unsigned int *)(tp); \
|
||||
isc_int32_t prev; \
|
||||
prev = isc_atomic_xadd(&(rp)->refs, 1); \
|
||||
REQUIRE(prev > 0); \
|
||||
if (_tmp != NULL) \
|
||||
*_tmp = prev + 1; \
|
||||
} while (0)
|
||||
|
||||
#define isc_refcount_decrement(rp, tp) \
|
||||
do { \
|
||||
unsigned int *_tmp = (unsigned int *)(tp); \
|
||||
isc_int32_t prev; \
|
||||
prev = isc_atomic_xadd(&(rp)->refs, -1); \
|
||||
REQUIRE(prev > 0); \
|
||||
if (_tmp != NULL) \
|
||||
*_tmp = prev - 1; \
|
||||
} while (0)
|
||||
|
||||
#else /* ISC_PLATFORM_HAVEXADD */
|
||||
|
||||
typedef struct isc_refcount {
|
||||
int refs;
|
||||
isc_mutex_t lock;
|
||||
} isc_refcount_t;
|
||||
|
||||
/*% Destroys a reference counter. */
|
||||
#define isc_refcount_destroy(rp) \
|
||||
do { \
|
||||
REQUIRE((rp)->refs == 0); \
|
||||
DESTROYLOCK(&(rp)->lock); \
|
||||
} while (0)
|
||||
|
||||
#define isc_refcount_current(rp) ((unsigned int)((rp)->refs))
|
||||
|
||||
/*% Increments the reference count, returning the new value in targetp if it's not NULL. */
|
||||
#define isc_refcount_increment0(rp, tp) \
|
||||
do { \
|
||||
unsigned int *_tmp = (unsigned int *)(tp); \
|
||||
LOCK(&(rp)->lock); \
|
||||
++((rp)->refs); \
|
||||
if (_tmp != NULL) \
|
||||
*_tmp = ((rp)->refs); \
|
||||
UNLOCK(&(rp)->lock); \
|
||||
} while (0)
|
||||
|
||||
#define isc_refcount_increment(rp, tp) \
|
||||
do { \
|
||||
unsigned int *_tmp = (unsigned int *)(tp); \
|
||||
LOCK(&(rp)->lock); \
|
||||
REQUIRE((rp)->refs > 0); \
|
||||
++((rp)->refs); \
|
||||
if (_tmp != NULL) \
|
||||
*_tmp = ((rp)->refs); \
|
||||
UNLOCK(&(rp)->lock); \
|
||||
} while (0)
|
||||
|
||||
/*% Decrements the reference count, returning the new value in targetp if it's not NULL. */
|
||||
#define isc_refcount_decrement(rp, tp) \
|
||||
do { \
|
||||
unsigned int *_tmp = (unsigned int *)(tp); \
|
||||
LOCK(&(rp)->lock); \
|
||||
REQUIRE((rp)->refs > 0); \
|
||||
--((rp)->refs); \
|
||||
if (_tmp != NULL) \
|
||||
*_tmp = ((rp)->refs); \
|
||||
UNLOCK(&(rp)->lock); \
|
||||
} while (0)
|
||||
|
||||
#endif /* ISC_PLATFORM_HAVEXADD */
|
||||
#else /* ISC_PLATFORM_USETHREADS */
|
||||
|
||||
typedef struct isc_refcount {
|
||||
int refs;
|
||||
} isc_refcount_t;
|
||||
|
||||
#define isc_refcount_destroy(rp) REQUIRE((rp)->refs == 0)
|
||||
#define isc_refcount_current(rp) ((unsigned int)((rp)->refs))
|
||||
|
||||
#define isc_refcount_increment0(rp, tp) \
|
||||
do { \
|
||||
unsigned int *_tmp = (unsigned int *)(tp); \
|
||||
int _n = ++(rp)->refs; \
|
||||
if (_tmp != NULL) \
|
||||
*_tmp = _n; \
|
||||
} while (0)
|
||||
|
||||
#define isc_refcount_increment(rp, tp) \
|
||||
do { \
|
||||
unsigned int *_tmp = (unsigned int *)(tp); \
|
||||
int _n; \
|
||||
REQUIRE((rp)->refs > 0); \
|
||||
_n = ++(rp)->refs; \
|
||||
if (_tmp != NULL) \
|
||||
*_tmp = _n; \
|
||||
} while (0)
|
||||
|
||||
#define isc_refcount_decrement(rp, tp) \
|
||||
do { \
|
||||
unsigned int *_tmp = (unsigned int *)(tp); \
|
||||
int _n; \
|
||||
REQUIRE((rp)->refs > 0); \
|
||||
_n = --(rp)->refs; \
|
||||
if (_tmp != NULL) \
|
||||
*_tmp = _n; \
|
||||
} while (0)
|
||||
|
||||
#endif /* ISC_PLATFORM_USETHREADS */
|
||||
|
||||
isc_result_t
|
||||
isc_refcount_init(isc_refcount_t *ref, unsigned int n);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_REFCOUNT_H */
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2002 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: region.h,v 1.1.12.2 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_REGION_H
|
||||
#define ISC_REGION_H 1
|
||||
|
||||
/*! \file isc/region.h */
|
||||
|
||||
#include <isc/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
struct isc_region {
|
||||
unsigned char * base;
|
||||
unsigned int length;
|
||||
};
|
||||
|
||||
struct isc_textregion {
|
||||
char * base;
|
||||
unsigned int length;
|
||||
};
|
||||
|
||||
/* XXXDCL questionable ... bears discussion. we have been putting off
|
||||
* discussing the region api.
|
||||
*/
|
||||
struct isc_constregion {
|
||||
const void * base;
|
||||
unsigned int length;
|
||||
};
|
||||
|
||||
struct isc_consttextregion {
|
||||
const char * base;
|
||||
unsigned int length;
|
||||
};
|
||||
|
||||
/*@{*/
|
||||
/*!
|
||||
* The region structure is not opaque, and is usually directly manipulated.
|
||||
* Some macros are defined below for convenience.
|
||||
*/
|
||||
|
||||
#define isc_region_consume(r,l) \
|
||||
do { \
|
||||
isc_region_t *_r = (r); \
|
||||
unsigned int _l = (l); \
|
||||
INSIST(_r->length >= _l); \
|
||||
_r->base += _l; \
|
||||
_r->length -= _l; \
|
||||
} while (0)
|
||||
|
||||
#define isc_textregion_consume(r,l) \
|
||||
do { \
|
||||
isc_textregion_t *_r = (r); \
|
||||
unsigned int _l = (l); \
|
||||
INSIST(_r->length >= _l); \
|
||||
_r->base += _l; \
|
||||
_r->length -= _l; \
|
||||
} while (0)
|
||||
|
||||
#define isc_constregion_consume(r,l) \
|
||||
do { \
|
||||
isc_constregion_t *_r = (r); \
|
||||
unsigned int _l = (l); \
|
||||
INSIST(_r->length >= _l); \
|
||||
_r->base += _l; \
|
||||
_r->length -= _l; \
|
||||
} while (0)
|
||||
/*@}*/
|
||||
|
||||
int
|
||||
isc_region_compare(isc_region_t *r1, isc_region_t *r2);
|
||||
/*%<
|
||||
* Compares the contents of two regions
|
||||
*
|
||||
* Requires:
|
||||
*\li 'r1' is a valid region
|
||||
*\li 'r2' is a valid region
|
||||
*
|
||||
* Returns:
|
||||
*\li < 0 if r1 is lexicographically less than r2
|
||||
*\li = 0 if r1 is lexicographically identical to r2
|
||||
*\li > 0 if r1 is lexicographically greater than r2
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* ISC_REGION_H */
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: resource.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_RESOURCE_H
|
||||
#define ISC_RESOURCE_H 1
|
||||
|
||||
/*! \file isc/resource.h */
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#define ISC_RESOURCE_UNLIMITED ((isc_resourcevalue_t)ISC_UINT64_MAX)
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_result_t
|
||||
isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value);
|
||||
/*%<
|
||||
* Set the maximum limit for a system resource.
|
||||
*
|
||||
* Notes:
|
||||
*\li If 'value' exceeds the maximum possible on the operating system,
|
||||
* it is silently limited to that maximum -- or to "infinity", if
|
||||
* the operating system has that concept. #ISC_RESOURCE_UNLIMITED
|
||||
* can be used to explicitly ask for the maximum.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'resource' is a valid member of the isc_resource_t enumeration.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS Success.
|
||||
*\li #ISC_R_NOTIMPLEMENTED 'resource' is not a type known by the OS.
|
||||
*\li #ISC_R_NOPERM The calling process did not have adequate permission
|
||||
* to change the resource limit.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_resource_getlimit(isc_resource_t resource, isc_resourcevalue_t *value);
|
||||
/*%<
|
||||
* Get the maximum limit for a system resource.
|
||||
*
|
||||
* Notes:
|
||||
*\li 'value' is set to the maximum limit.
|
||||
*
|
||||
*\li #ISC_RESOURCE_UNLIMITED is the maximum value of isc_resourcevalue_t.
|
||||
*
|
||||
*\li On many (all?) Unix systems, RLIM_INFINITY is a valid value that is
|
||||
* significantly less than #ISC_RESOURCE_UNLIMITED, but which in practice
|
||||
* behaves the same.
|
||||
*
|
||||
*\li The current ISC libdns configuration file parser assigns a value
|
||||
* of ISC_UINT32_MAX for a size_spec of "unlimited" and ISC_UNIT32_MAX - 1
|
||||
* for "default", the latter of which is supposed to represent "the
|
||||
* limit that was in force when the server started". Since these are
|
||||
* valid values in the middle of the range of isc_resourcevalue_t,
|
||||
* there is the possibility for confusion over what exactly those
|
||||
* particular values are supposed to represent in a particular context --
|
||||
* discrete integral values or generalized concepts.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'resource' is a valid member of the isc_resource_t enumeration.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS Success.
|
||||
*\li #ISC_R_NOTIMPLEMENTED 'resource' is not a type known by the OS.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_resource_getcurlimit(isc_resource_t resource, isc_resourcevalue_t *value);
|
||||
/*%<
|
||||
* Same as isc_resource_getlimit(), but returns the current (soft) limit.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS Success.
|
||||
*\li #ISC_R_NOTIMPLEMENTED 'resource' is not a type known by the OS.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_RESOURCE_H */
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2009, 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2001, 2003 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: result.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_RESULT_H
|
||||
#define ISC_RESULT_H 1
|
||||
|
||||
/*! \file isc/result.h */
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#define ISC_R_SUCCESS 0 /*%< success */
|
||||
#define ISC_R_NOMEMORY 1 /*%< out of memory */
|
||||
#define ISC_R_TIMEDOUT 2 /*%< timed out */
|
||||
#define ISC_R_NOTHREADS 3 /*%< no available threads */
|
||||
#define ISC_R_ADDRNOTAVAIL 4 /*%< address not available */
|
||||
#define ISC_R_ADDRINUSE 5 /*%< address in use */
|
||||
#define ISC_R_NOPERM 6 /*%< permission denied */
|
||||
#define ISC_R_NOCONN 7 /*%< no pending connections */
|
||||
#define ISC_R_NETUNREACH 8 /*%< network unreachable */
|
||||
#define ISC_R_HOSTUNREACH 9 /*%< host unreachable */
|
||||
#define ISC_R_NETDOWN 10 /*%< network down */
|
||||
#define ISC_R_HOSTDOWN 11 /*%< host down */
|
||||
#define ISC_R_CONNREFUSED 12 /*%< connection refused */
|
||||
#define ISC_R_NORESOURCES 13 /*%< not enough free resources */
|
||||
#define ISC_R_EOF 14 /*%< end of file */
|
||||
#define ISC_R_BOUND 15 /*%< socket already bound */
|
||||
#define ISC_R_RELOAD 16 /*%< reload */
|
||||
#define ISC_R_SUSPEND ISC_R_RELOAD /*%< alias of 'reload' */
|
||||
#define ISC_R_LOCKBUSY 17 /*%< lock busy */
|
||||
#define ISC_R_EXISTS 18 /*%< already exists */
|
||||
#define ISC_R_NOSPACE 19 /*%< ran out of space */
|
||||
#define ISC_R_CANCELED 20 /*%< operation canceled */
|
||||
#define ISC_R_NOTBOUND 21 /*%< socket is not bound */
|
||||
#define ISC_R_SHUTTINGDOWN 22 /*%< shutting down */
|
||||
#define ISC_R_NOTFOUND 23 /*%< not found */
|
||||
#define ISC_R_UNEXPECTEDEND 24 /*%< unexpected end of input */
|
||||
#define ISC_R_FAILURE 25 /*%< generic failure */
|
||||
#define ISC_R_IOERROR 26 /*%< I/O error */
|
||||
#define ISC_R_NOTIMPLEMENTED 27 /*%< not implemented */
|
||||
#define ISC_R_UNBALANCED 28 /*%< unbalanced parentheses */
|
||||
#define ISC_R_NOMORE 29 /*%< no more */
|
||||
#define ISC_R_INVALIDFILE 30 /*%< invalid file */
|
||||
#define ISC_R_BADBASE64 31 /*%< bad base64 encoding */
|
||||
#define ISC_R_UNEXPECTEDTOKEN 32 /*%< unexpected token */
|
||||
#define ISC_R_QUOTA 33 /*%< quota reached */
|
||||
#define ISC_R_UNEXPECTED 34 /*%< unexpected error */
|
||||
#define ISC_R_ALREADYRUNNING 35 /*%< already running */
|
||||
#define ISC_R_IGNORE 36 /*%< ignore */
|
||||
#define ISC_R_MASKNONCONTIG 37 /*%< addr mask not contiguous */
|
||||
#define ISC_R_FILENOTFOUND 38 /*%< file not found */
|
||||
#define ISC_R_FILEEXISTS 39 /*%< file already exists */
|
||||
#define ISC_R_NOTCONNECTED 40 /*%< socket is not connected */
|
||||
#define ISC_R_RANGE 41 /*%< out of range */
|
||||
#define ISC_R_NOENTROPY 42 /*%< out of entropy */
|
||||
#define ISC_R_MULTICAST 43 /*%< invalid use of multicast */
|
||||
#define ISC_R_NOTFILE 44 /*%< not a file */
|
||||
#define ISC_R_NOTDIRECTORY 45 /*%< not a directory */
|
||||
#define ISC_R_QUEUEFULL 46 /*%< queue is full */
|
||||
#define ISC_R_FAMILYMISMATCH 47 /*%< address family mismatch */
|
||||
#define ISC_R_FAMILYNOSUPPORT 48 /*%< AF not supported */
|
||||
#define ISC_R_BADHEX 49 /*%< bad hex encoding */
|
||||
#define ISC_R_TOOMANYOPENFILES 50 /*%< too many open files */
|
||||
#define ISC_R_NOTBLOCKING 51 /*%< not blocking */
|
||||
#define ISC_R_UNBALANCEDQUOTES 52 /*%< unbalanced quotes */
|
||||
#define ISC_R_INPROGRESS 53 /*%< operation in progress */
|
||||
#define ISC_R_CONNECTIONRESET 54 /*%< connection reset */
|
||||
#define ISC_R_SOFTQUOTA 55 /*%< soft quota reached */
|
||||
#define ISC_R_BADNUMBER 56 /*%< not a valid number */
|
||||
#define ISC_R_DISABLED 57 /*%< disabled */
|
||||
#define ISC_R_MAXSIZE 58 /*%< max size */
|
||||
#define ISC_R_BADADDRESSFORM 59 /*%< invalid address format */
|
||||
#define ISC_R_BADBASE32 60 /*%< bad base32 encoding */
|
||||
#define ISC_R_UNSET 61 /*%< unset */
|
||||
|
||||
/*% Not a result code: the number of results. */
|
||||
#define ISC_R_NRESULTS 62
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
const char *
|
||||
isc_result_totext(isc_result_t);
|
||||
/*%<
|
||||
* Convert an isc_result_t into a string message describing the result.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_result_register(unsigned int base, unsigned int nresults,
|
||||
const char **text, isc_msgcat_t *msgcat, int set);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_RESULT_H */
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: resultclass.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_RESULTCLASS_H
|
||||
#define ISC_RESULTCLASS_H 1
|
||||
|
||||
|
||||
/*! \file isc/resultclass.h
|
||||
* \brief Registry of Predefined Result Type Classes
|
||||
*
|
||||
* A result class number is an unsigned 16 bit number. Each class may
|
||||
* contain up to 65536 results. A result code is formed by adding the
|
||||
* result number within the class to the class number multiplied by 65536.
|
||||
*
|
||||
* Classes < 1024 are reserved for ISC use.
|
||||
* Result classes >= 1024 and <= 65535 are reserved for application use.
|
||||
*/
|
||||
|
||||
#define ISC_RESULTCLASS_FROMNUM(num) ((num) << 16)
|
||||
#define ISC_RESULTCLASS_TONUM(rclass) ((rclass) >> 16)
|
||||
#define ISC_RESULTCLASS_SIZE 65536
|
||||
#define ISC_RESULTCLASS_INCLASS(rclass, result) \
|
||||
((rclass) == ((result) & 0xFFFF0000))
|
||||
|
||||
|
||||
#define ISC_RESULTCLASS_ISC ISC_RESULTCLASS_FROMNUM(0)
|
||||
#define ISC_RESULTCLASS_DNS ISC_RESULTCLASS_FROMNUM(1)
|
||||
#define ISC_RESULTCLASS_DST ISC_RESULTCLASS_FROMNUM(2)
|
||||
#define ISC_RESULTCLASS_DNSRCODE ISC_RESULTCLASS_FROMNUM(3)
|
||||
#define ISC_RESULTCLASS_OMAPI ISC_RESULTCLASS_FROMNUM(4)
|
||||
#define ISC_RESULTCLASS_ISCCC ISC_RESULTCLASS_FROMNUM(5)
|
||||
#define ISC_RESULTCLASS_DHCP ISC_RESULTCLASS_FROMNUM(6)
|
||||
|
||||
|
||||
#endif /* ISC_RESULTCLASS_H */
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2001, 2003 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: rwlock.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_RWLOCK_H
|
||||
#define ISC_RWLOCK_H 1
|
||||
|
||||
/*! \file isc/rwlock.h */
|
||||
|
||||
#include <isc/condition.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
typedef enum {
|
||||
isc_rwlocktype_none = 0,
|
||||
isc_rwlocktype_read,
|
||||
isc_rwlocktype_write
|
||||
} isc_rwlocktype_t;
|
||||
|
||||
#ifdef ISC_PLATFORM_USETHREADS
|
||||
#if defined(ISC_PLATFORM_HAVEXADD) && defined(ISC_PLATFORM_HAVECMPXCHG)
|
||||
#define ISC_RWLOCK_USEATOMIC 1
|
||||
#endif
|
||||
|
||||
struct isc_rwlock {
|
||||
/* Unlocked. */
|
||||
unsigned int magic;
|
||||
isc_mutex_t lock;
|
||||
|
||||
#if defined(ISC_PLATFORM_HAVEXADD) && defined(ISC_PLATFORM_HAVECMPXCHG)
|
||||
/*
|
||||
* When some atomic instructions with hardware assistance are
|
||||
* available, rwlock will use those so that concurrent readers do not
|
||||
* interfere with each other through mutex as long as no writers
|
||||
* appear, massively reducing the lock overhead in the typical case.
|
||||
*
|
||||
* The basic algorithm of this approach is the "simple
|
||||
* writer-preference lock" shown in the following URL:
|
||||
* http://www.cs.rochester.edu/u/scott/synchronization/pseudocode/rw.html
|
||||
* but our implementation does not rely on the spin lock unlike the
|
||||
* original algorithm to be more portable as a user space application.
|
||||
*/
|
||||
|
||||
/* Read or modified atomically. */
|
||||
isc_int32_t write_requests;
|
||||
isc_int32_t write_completions;
|
||||
isc_int32_t cnt_and_flag;
|
||||
|
||||
/* Locked by lock. */
|
||||
isc_condition_t readable;
|
||||
isc_condition_t writeable;
|
||||
unsigned int readers_waiting;
|
||||
|
||||
/* Locked by rwlock itself. */
|
||||
unsigned int write_granted;
|
||||
|
||||
/* Unlocked. */
|
||||
unsigned int write_quota;
|
||||
|
||||
#else /* ISC_PLATFORM_HAVEXADD && ISC_PLATFORM_HAVECMPXCHG */
|
||||
|
||||
/*%< Locked by lock. */
|
||||
isc_condition_t readable;
|
||||
isc_condition_t writeable;
|
||||
isc_rwlocktype_t type;
|
||||
|
||||
/*% The number of threads that have the lock. */
|
||||
unsigned int active;
|
||||
|
||||
/*%
|
||||
* The number of lock grants made since the lock was last switched
|
||||
* from reading to writing or vice versa; used in determining
|
||||
* when the quota is reached and it is time to switch.
|
||||
*/
|
||||
unsigned int granted;
|
||||
|
||||
unsigned int readers_waiting;
|
||||
unsigned int writers_waiting;
|
||||
unsigned int read_quota;
|
||||
unsigned int write_quota;
|
||||
isc_rwlocktype_t original;
|
||||
#endif /* ISC_PLATFORM_HAVEXADD && ISC_PLATFORM_HAVECMPXCHG */
|
||||
};
|
||||
#else /* ISC_PLATFORM_USETHREADS */
|
||||
struct isc_rwlock {
|
||||
unsigned int magic;
|
||||
isc_rwlocktype_t type;
|
||||
unsigned int active;
|
||||
};
|
||||
#endif /* ISC_PLATFORM_USETHREADS */
|
||||
|
||||
|
||||
isc_result_t
|
||||
isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
|
||||
unsigned int write_quota);
|
||||
|
||||
isc_result_t
|
||||
isc_rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type);
|
||||
|
||||
isc_result_t
|
||||
isc_rwlock_trylock(isc_rwlock_t *rwl, isc_rwlocktype_t type);
|
||||
|
||||
isc_result_t
|
||||
isc_rwlock_unlock(isc_rwlock_t *rwl, isc_rwlocktype_t type);
|
||||
|
||||
isc_result_t
|
||||
isc_rwlock_tryupgrade(isc_rwlock_t *rwl);
|
||||
|
||||
void
|
||||
isc_rwlock_downgrade(isc_rwlock_t *rwl);
|
||||
|
||||
void
|
||||
isc_rwlock_destroy(isc_rwlock_t *rwl);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_RWLOCK_H */
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: serial.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_SERIAL_H
|
||||
#define ISC_SERIAL_H 1
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/*! \file isc/serial.h
|
||||
* \brief Implement 32 bit serial space arithmetic comparison functions.
|
||||
* Note: Undefined results are returned as ISC_FALSE.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Functions
|
||||
***/
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_boolean_t
|
||||
isc_serial_lt(isc_uint32_t a, isc_uint32_t b);
|
||||
/*%<
|
||||
* Return true if 'a' < 'b' otherwise false.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_serial_gt(isc_uint32_t a, isc_uint32_t b);
|
||||
/*%<
|
||||
* Return true if 'a' > 'b' otherwise false.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_serial_le(isc_uint32_t a, isc_uint32_t b);
|
||||
/*%<
|
||||
* Return true if 'a' <= 'b' otherwise false.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_serial_ge(isc_uint32_t a, isc_uint32_t b);
|
||||
/*%<
|
||||
* Return true if 'a' >= 'b' otherwise false.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_serial_eq(isc_uint32_t a, isc_uint32_t b);
|
||||
/*%<
|
||||
* Return true if 'a' == 'b' otherwise false.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_serial_ne(isc_uint32_t a, isc_uint32_t b);
|
||||
/*%<
|
||||
* Return true if 'a' != 'b' otherwise false.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_SERIAL_H */
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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.
|
||||
*/
|
||||
|
||||
#ifndef ISC_SHA1_H
|
||||
#define ISC_SHA1_H 1
|
||||
|
||||
/* $Id: sha1.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
/* $NetBSD: sha1.h,v 1.2 1998/05/29 22:55:44 thorpej Exp $ */
|
||||
|
||||
/*! \file isc/sha1.h
|
||||
* \brief SHA-1 in C
|
||||
* \author By Steve Reid <steve@edmweb.com>
|
||||
* \note 100% Public Domain
|
||||
*/
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#define ISC_SHA1_DIGESTLENGTH 20U
|
||||
#define ISC_SHA1_BLOCK_LENGTH 64U
|
||||
|
||||
#ifdef ISC_PLATFORM_OPENSSLHASH
|
||||
#include <openssl/evp.h>
|
||||
|
||||
typedef EVP_MD_CTX isc_sha1_t;
|
||||
|
||||
#else
|
||||
|
||||
typedef struct {
|
||||
isc_uint32_t state[5];
|
||||
isc_uint32_t count[2];
|
||||
unsigned char buffer[ISC_SHA1_BLOCK_LENGTH];
|
||||
} isc_sha1_t;
|
||||
#endif
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
void
|
||||
isc_sha1_init(isc_sha1_t *ctx);
|
||||
|
||||
void
|
||||
isc_sha1_invalidate(isc_sha1_t *ctx);
|
||||
|
||||
void
|
||||
isc_sha1_update(isc_sha1_t *ctx, const unsigned char *data, unsigned int len);
|
||||
|
||||
void
|
||||
isc_sha1_final(isc_sha1_t *ctx, unsigned char *digest);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_SHA1_H */
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: sha2.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
/* $FreeBSD: src/sys/crypto/sha2/sha2.h,v 1.1.2.1 2001/07/03 11:01:36 ume Exp $ */
|
||||
/* $KAME: sha2.h,v 1.3 2001/03/12 08:27:48 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* sha2.h
|
||||
*
|
||||
* Version 1.0.0beta1
|
||||
*
|
||||
* Written by Aaron D. Gifford <me@aarongifford.com>
|
||||
*
|
||||
* Copyright 2000 Aaron D. Gifford. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the names of contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTOR(S) ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ISC_SHA2_H
|
||||
#define ISC_SHA2_H
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/*** SHA-224/256/384/512 Various Length Definitions ***********************/
|
||||
|
||||
#define ISC_SHA224_BLOCK_LENGTH 64U
|
||||
#define ISC_SHA224_DIGESTLENGTH 28U
|
||||
#define ISC_SHA224_DIGESTSTRINGLENGTH (ISC_SHA224_DIGESTLENGTH * 2 + 1)
|
||||
#define ISC_SHA256_BLOCK_LENGTH 64U
|
||||
#define ISC_SHA256_DIGESTLENGTH 32U
|
||||
#define ISC_SHA256_DIGESTSTRINGLENGTH (ISC_SHA256_DIGESTLENGTH * 2 + 1)
|
||||
#define ISC_SHA384_BLOCK_LENGTH 128
|
||||
#define ISC_SHA384_DIGESTLENGTH 48U
|
||||
#define ISC_SHA384_DIGESTSTRINGLENGTH (ISC_SHA384_DIGESTLENGTH * 2 + 1)
|
||||
#define ISC_SHA512_BLOCK_LENGTH 128U
|
||||
#define ISC_SHA512_DIGESTLENGTH 64U
|
||||
#define ISC_SHA512_DIGESTSTRINGLENGTH (ISC_SHA512_DIGESTLENGTH * 2 + 1)
|
||||
|
||||
/*** SHA-256/384/512 Context Structures *******************************/
|
||||
|
||||
#ifdef ISC_PLATFORM_OPENSSLHASH
|
||||
#include <openssl/evp.h>
|
||||
|
||||
typedef EVP_MD_CTX isc_sha256_t;
|
||||
typedef EVP_MD_CTX isc_sha512_t;
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Keep buffer immediately after bitcount to preserve alignment.
|
||||
*/
|
||||
typedef struct {
|
||||
isc_uint32_t state[8];
|
||||
isc_uint64_t bitcount;
|
||||
isc_uint8_t buffer[ISC_SHA256_BLOCK_LENGTH];
|
||||
} isc_sha256_t;
|
||||
|
||||
/*
|
||||
* Keep buffer immediately after bitcount to preserve alignment.
|
||||
*/
|
||||
typedef struct {
|
||||
isc_uint64_t state[8];
|
||||
isc_uint64_t bitcount[2];
|
||||
isc_uint8_t buffer[ISC_SHA512_BLOCK_LENGTH];
|
||||
} isc_sha512_t;
|
||||
#endif
|
||||
|
||||
typedef isc_sha256_t isc_sha224_t;
|
||||
typedef isc_sha512_t isc_sha384_t;
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*** SHA-224/256/384/512 Function Prototypes ******************************/
|
||||
|
||||
void isc_sha224_init (isc_sha224_t *);
|
||||
void isc_sha224_invalidate (isc_sha224_t *);
|
||||
void isc_sha224_update (isc_sha224_t *, const isc_uint8_t *, size_t);
|
||||
void isc_sha224_final (isc_uint8_t[ISC_SHA224_DIGESTLENGTH], isc_sha224_t *);
|
||||
char *isc_sha224_end (isc_sha224_t *, char[ISC_SHA224_DIGESTSTRINGLENGTH]);
|
||||
char *isc_sha224_data (const isc_uint8_t *, size_t, char[ISC_SHA224_DIGESTSTRINGLENGTH]);
|
||||
|
||||
void isc_sha256_init (isc_sha256_t *);
|
||||
void isc_sha256_invalidate (isc_sha256_t *);
|
||||
void isc_sha256_update (isc_sha256_t *, const isc_uint8_t *, size_t);
|
||||
void isc_sha256_final (isc_uint8_t[ISC_SHA256_DIGESTLENGTH], isc_sha256_t *);
|
||||
char *isc_sha256_end (isc_sha256_t *, char[ISC_SHA256_DIGESTSTRINGLENGTH]);
|
||||
char *isc_sha256_data (const isc_uint8_t *, size_t, char[ISC_SHA256_DIGESTSTRINGLENGTH]);
|
||||
|
||||
void isc_sha384_init (isc_sha384_t *);
|
||||
void isc_sha384_invalidate (isc_sha384_t *);
|
||||
void isc_sha384_update (isc_sha384_t *, const isc_uint8_t *, size_t);
|
||||
void isc_sha384_final (isc_uint8_t[ISC_SHA384_DIGESTLENGTH], isc_sha384_t *);
|
||||
char *isc_sha384_end (isc_sha384_t *, char[ISC_SHA384_DIGESTSTRINGLENGTH]);
|
||||
char *isc_sha384_data (const isc_uint8_t *, size_t, char[ISC_SHA384_DIGESTSTRINGLENGTH]);
|
||||
|
||||
void isc_sha512_init (isc_sha512_t *);
|
||||
void isc_sha512_invalidate (isc_sha512_t *);
|
||||
void isc_sha512_update (isc_sha512_t *, const isc_uint8_t *, size_t);
|
||||
void isc_sha512_final (isc_uint8_t[ISC_SHA512_DIGESTLENGTH], isc_sha512_t *);
|
||||
char *isc_sha512_end (isc_sha512_t *, char[ISC_SHA512_DIGESTSTRINGLENGTH]);
|
||||
char *isc_sha512_data (const isc_uint8_t *, size_t, char[ISC_SHA512_DIGESTSTRINGLENGTH]);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_SHA2_H */
|
||||
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2003 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: sockaddr.h,v 1.1.12.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_SOCKADDR_H
|
||||
#define ISC_SOCKADDR_H 1
|
||||
|
||||
/*! \file isc/sockaddr.h */
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/net.h>
|
||||
#include <isc/types.h>
|
||||
#ifdef ISC_PLATFORM_HAVESYSUNH
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
|
||||
struct isc_sockaddr {
|
||||
union {
|
||||
struct sockaddr sa;
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in6 sin6;
|
||||
#ifdef ISC_PLATFORM_HAVESYSUNH
|
||||
struct sockaddr_un sunix;
|
||||
#endif
|
||||
} type;
|
||||
unsigned int length; /* XXXRTH beginning? */
|
||||
ISC_LINK(struct isc_sockaddr) link;
|
||||
};
|
||||
|
||||
typedef ISC_LIST(struct isc_sockaddr) isc_sockaddrlist_t;
|
||||
|
||||
#define ISC_SOCKADDR_CMPADDR 0x0001 /*%< compare the address
|
||||
* sin_addr/sin6_addr */
|
||||
#define ISC_SOCKADDR_CMPPORT 0x0002 /*%< compare the port
|
||||
* sin_port/sin6_port */
|
||||
#define ISC_SOCKADDR_CMPSCOPE 0x0004 /*%< compare the scope
|
||||
* sin6_scope */
|
||||
#define ISC_SOCKADDR_CMPSCOPEZERO 0x0008 /*%< when comparing scopes
|
||||
* zero scopes always match */
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_boolean_t
|
||||
isc_sockaddr_compare(const isc_sockaddr_t *a, const isc_sockaddr_t *b,
|
||||
unsigned int flags);
|
||||
/*%<
|
||||
* Compare the elements of the two address ('a' and 'b') as specified
|
||||
* by 'flags' and report if they are equal or not.
|
||||
*
|
||||
* 'flags' is set from ISC_SOCKADDR_CMP*.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_sockaddr_equal(const isc_sockaddr_t *a, const isc_sockaddr_t *b);
|
||||
/*%<
|
||||
* Return ISC_TRUE iff the socket addresses 'a' and 'b' are equal.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_sockaddr_eqaddr(const isc_sockaddr_t *a, const isc_sockaddr_t *b);
|
||||
/*%<
|
||||
* Return ISC_TRUE iff the address parts of the socket addresses
|
||||
* 'a' and 'b' are equal, ignoring the ports.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_sockaddr_eqaddrprefix(const isc_sockaddr_t *a, const isc_sockaddr_t *b,
|
||||
unsigned int prefixlen);
|
||||
/*%<
|
||||
* Return ISC_TRUE iff the most significant 'prefixlen' bits of the
|
||||
* socket addresses 'a' and 'b' are equal, ignoring the ports.
|
||||
* If 'b''s scope is zero then 'a''s scope will be ignored.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_sockaddr_hash(const isc_sockaddr_t *sockaddr, isc_boolean_t address_only);
|
||||
/*%<
|
||||
* Return a hash value for the socket address 'sockaddr'. If 'address_only'
|
||||
* is ISC_TRUE, the hash value will not depend on the port.
|
||||
*
|
||||
* IPv6 addresses containing mapped IPv4 addresses generate the same hash
|
||||
* value as the equivalent IPv4 address.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_sockaddr_any(isc_sockaddr_t *sockaddr);
|
||||
/*%<
|
||||
* Return the IPv4 wildcard address.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_sockaddr_any6(isc_sockaddr_t *sockaddr);
|
||||
/*%<
|
||||
* Return the IPv6 wildcard address.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_sockaddr_anyofpf(isc_sockaddr_t *sockaddr, int family);
|
||||
/*%<
|
||||
* Set '*sockaddr' to the wildcard address of protocol family
|
||||
* 'family'.
|
||||
*
|
||||
* Requires:
|
||||
* \li 'family' is AF_INET or AF_INET6.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_sockaddr_fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina,
|
||||
in_port_t port);
|
||||
/*%<
|
||||
* Construct an isc_sockaddr_t from an IPv4 address and port.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_sockaddr_fromin6(isc_sockaddr_t *sockaddr, const struct in6_addr *ina6,
|
||||
in_port_t port);
|
||||
/*%<
|
||||
* Construct an isc_sockaddr_t from an IPv6 address and port.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_sockaddr_v6fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina,
|
||||
in_port_t port);
|
||||
/*%<
|
||||
* Construct an IPv6 isc_sockaddr_t representing a mapped IPv4 address.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_sockaddr_fromnetaddr(isc_sockaddr_t *sockaddr, const isc_netaddr_t *na,
|
||||
in_port_t port);
|
||||
/*%<
|
||||
* Construct an isc_sockaddr_t from an isc_netaddr_t and port.
|
||||
*/
|
||||
|
||||
int
|
||||
isc_sockaddr_pf(const isc_sockaddr_t *sockaddr);
|
||||
/*%<
|
||||
* Get the protocol family of 'sockaddr'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'sockaddr' is a valid sockaddr with an address family of AF_INET
|
||||
* or AF_INET6.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li The protocol family of 'sockaddr', e.g. PF_INET or PF_INET6.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_sockaddr_setport(isc_sockaddr_t *sockaddr, in_port_t port);
|
||||
/*%<
|
||||
* Set the port of 'sockaddr' to 'port'.
|
||||
*/
|
||||
|
||||
in_port_t
|
||||
isc_sockaddr_getport(const isc_sockaddr_t *sockaddr);
|
||||
/*%<
|
||||
* Get the port stored in 'sockaddr'.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_sockaddr_totext(const isc_sockaddr_t *sockaddr, isc_buffer_t *target);
|
||||
/*%<
|
||||
* Append a text representation of 'sockaddr' to the buffer 'target'.
|
||||
* The text will include both the IP address (v4 or v6) and the port.
|
||||
* The text is null terminated, but the terminating null is not
|
||||
* part of the buffer's used region.
|
||||
*
|
||||
* Returns:
|
||||
* \li ISC_R_SUCCESS
|
||||
* \li ISC_R_NOSPACE The text or the null termination did not fit.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_sockaddr_format(const isc_sockaddr_t *sa, char *array, unsigned int size);
|
||||
/*%<
|
||||
* Format a human-readable representation of the socket address '*sa'
|
||||
* into the character array 'array', which is of size 'size'.
|
||||
* The resulting string is guaranteed to be null-terminated.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_sockaddr_ismulticast(const isc_sockaddr_t *sa);
|
||||
/*%<
|
||||
* Returns #ISC_TRUE if the address is a multicast address.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_sockaddr_isexperimental(const isc_sockaddr_t *sa);
|
||||
/*
|
||||
* Returns ISC_TRUE if the address is a experimental (CLASS E) address.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_sockaddr_islinklocal(const isc_sockaddr_t *sa);
|
||||
/*%<
|
||||
* Returns ISC_TRUE if the address is a link local address.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_sockaddr_issitelocal(const isc_sockaddr_t *sa);
|
||||
/*%<
|
||||
* Returns ISC_TRUE if the address is a sitelocal address.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_sockaddr_frompath(isc_sockaddr_t *sockaddr, const char *path);
|
||||
/*
|
||||
* Create a UNIX domain sockaddr that refers to path.
|
||||
*
|
||||
* Returns:
|
||||
* \li ISC_R_NOSPACE
|
||||
* \li ISC_R_NOTIMPLEMENTED
|
||||
* \li ISC_R_SUCCESS
|
||||
*/
|
||||
|
||||
#define ISC_SOCKADDR_FORMATSIZE \
|
||||
sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:XXX.XXX.XXX.XXX%SSSSSSSSSS#YYYYY")
|
||||
/*%<
|
||||
* Minimum size of array to pass to isc_sockaddr_format().
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_SOCKADDR_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: stat.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_STAT_H
|
||||
#define ISC_STAT_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*
|
||||
* Portable netdb.h support.
|
||||
*
|
||||
* This module is responsible for defining S_IS??? macros.
|
||||
*
|
||||
* MP:
|
||||
* No impact.
|
||||
*
|
||||
* Reliability:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* Resources:
|
||||
* N/A.
|
||||
*
|
||||
* Security:
|
||||
* No anticipated impact.
|
||||
*
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports.
|
||||
***/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#endif /* ISC_STAT_H */
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (C) 2009, 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: stats.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_STATS_H
|
||||
#define ISC_STATS_H 1
|
||||
|
||||
/*! \file isc/stats.h */
|
||||
|
||||
#include <isc/types.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*%<
|
||||
* Flag(s) for isc_stats_dump().
|
||||
*/
|
||||
#define ISC_STATSDUMP_VERBOSE 0x00000001 /*%< dump 0-value counters */
|
||||
|
||||
/*%<
|
||||
* Dump callback type.
|
||||
*/
|
||||
typedef void (*isc_stats_dumper_t)(isc_statscounter_t, isc_uint64_t, void *);
|
||||
|
||||
isc_result_t
|
||||
isc_stats_create(isc_mem_t *mctx, isc_stats_t **statsp, int ncounters);
|
||||
/*%<
|
||||
* Create a statistics counter structure of general type. It counts a general
|
||||
* set of counters indexed by an ID between 0 and ncounters -1.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'mctx' must be a valid memory context.
|
||||
*
|
||||
*\li 'statsp' != NULL && '*statsp' == NULL.
|
||||
*
|
||||
* Returns:
|
||||
*\li ISC_R_SUCCESS -- all ok
|
||||
*
|
||||
*\li anything else -- failure
|
||||
*/
|
||||
|
||||
void
|
||||
isc_stats_attach(isc_stats_t *stats, isc_stats_t **statsp);
|
||||
/*%<
|
||||
* Attach to a statistics set.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'stats' is a valid isc_stats_t.
|
||||
*
|
||||
*\li 'statsp' != NULL && '*statsp' == NULL
|
||||
*/
|
||||
|
||||
void
|
||||
isc_stats_detach(isc_stats_t **statsp);
|
||||
/*%<
|
||||
* Detaches from the statistics set.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'statsp' != NULL and '*statsp' is a valid isc_stats_t.
|
||||
*/
|
||||
|
||||
int
|
||||
isc_stats_ncounters(isc_stats_t *stats);
|
||||
/*%<
|
||||
* Returns the number of counters contained in stats.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'stats' is a valid isc_stats_t.
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
isc_stats_increment(isc_stats_t *stats, isc_statscounter_t counter);
|
||||
/*%<
|
||||
* Increment the counter-th counter of stats.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'stats' is a valid isc_stats_t.
|
||||
*
|
||||
*\li counter is less than the maximum available ID for the stats specified
|
||||
* on creation.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_stats_decrement(isc_stats_t *stats, isc_statscounter_t counter);
|
||||
/*%<
|
||||
* Decrement the counter-th counter of stats.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'stats' is a valid isc_stats_t.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_stats_dump(isc_stats_t *stats, isc_stats_dumper_t dump_fn, void *arg,
|
||||
unsigned int options);
|
||||
/*%<
|
||||
* Dump the current statistics counters in a specified way. For each counter
|
||||
* in stats, dump_fn is called with its current value and the given argument
|
||||
* arg. By default counters that have a value of 0 is skipped; if options has
|
||||
* the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'stats' is a valid isc_stats_t.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_STATS_H */
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: stdio.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_STDIO_H
|
||||
#define ISC_STDIO_H 1
|
||||
|
||||
/*! \file isc/stdio.h */
|
||||
|
||||
/*%
|
||||
* These functions are wrappers around the corresponding stdio functions.
|
||||
*
|
||||
* They return a detailed error code in the form of an an isc_result_t. ANSI C
|
||||
* does not guarantee that stdio functions set errno, hence these functions
|
||||
* must use platform dependent methods (e.g., the POSIX errno) to construct the
|
||||
* error code.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/result.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*% Open */
|
||||
isc_result_t
|
||||
isc_stdio_open(const char *filename, const char *mode, FILE **fp);
|
||||
|
||||
/*% Close */
|
||||
isc_result_t
|
||||
isc_stdio_close(FILE *f);
|
||||
|
||||
/*% Seek */
|
||||
isc_result_t
|
||||
isc_stdio_seek(FILE *f, long offset, int whence);
|
||||
|
||||
/*% Read */
|
||||
isc_result_t
|
||||
isc_stdio_read(void *ptr, size_t size, size_t nmemb, FILE *f,
|
||||
size_t *nret);
|
||||
|
||||
/*% Write */
|
||||
isc_result_t
|
||||
isc_stdio_write(const void *ptr, size_t size, size_t nmemb, FILE *f,
|
||||
size_t *nret);
|
||||
|
||||
/*% Flush */
|
||||
isc_result_t
|
||||
isc_stdio_flush(FILE *f);
|
||||
|
||||
isc_result_t
|
||||
isc_stdio_sync(FILE *f);
|
||||
/*%<
|
||||
* Invoke fsync() on the file descriptor underlying an stdio stream, or an
|
||||
* equivalent system-dependent operation. Note that this function has no
|
||||
* direct counterpart in the stdio library.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_STDIO_H */
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2003 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: stdlib.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_STDLIB_H
|
||||
#define ISC_STDLIB_H 1
|
||||
|
||||
/*! \file isc/stdlib.h */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDSTRTOUL
|
||||
#define strtoul isc_strtoul
|
||||
#endif
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
unsigned long isc_strtoul(const char *, char **, int);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2004, 2005, 2007, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: stdtime.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_STDTIME_H
|
||||
#define ISC_STDTIME_H 1
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/int.h>
|
||||
|
||||
/*%
|
||||
* It's public information that 'isc_stdtime_t' is an unsigned integral type.
|
||||
* Applications that want maximum portability should not assume anything
|
||||
* about its size.
|
||||
*/
|
||||
typedef isc_uint32_t isc_stdtime_t;
|
||||
|
||||
/* but this flag helps... */
|
||||
#define STDTIME_ON_32BITS 1
|
||||
|
||||
/*
|
||||
* isc_stdtime32_t is a 32-bit version of isc_stdtime_t. A variable of this
|
||||
* type should only be used as an opaque integer (e.g.,) to compare two
|
||||
* time values.
|
||||
*/
|
||||
typedef isc_uint32_t isc_stdtime32_t;
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
/* */
|
||||
void
|
||||
isc_stdtime_get(isc_stdtime_t *t);
|
||||
/*%<
|
||||
* Set 't' to the number of seconds since 00:00:00 UTC, January 1, 1970.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 't' is a valid pointer.
|
||||
*/
|
||||
|
||||
#define isc_stdtime_convert32(t, t32p) (*(t32p) = t)
|
||||
/*
|
||||
* Convert the standard time to its 32-bit version.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_STDTIME_H */
|
||||
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: string.h,v 1.1.12.2 2016-09-26 08:40:10 jren Exp $ */
|
||||
|
||||
#ifndef ISC_STRING_H
|
||||
#define ISC_STRING_H 1
|
||||
|
||||
/*! \file isc/string.h */
|
||||
|
||||
#include <isc/formatcheck.h>
|
||||
#include <isc/int.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/platform.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef ISC_PLATFORM_HAVESTRINGSH
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#define ISC_STRING_MAGIC 0x5e
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
isc_uint64_t
|
||||
isc_string_touint64(char *source, char **endp, int base);
|
||||
/*%<
|
||||
* Convert the string pointed to by 'source' to isc_uint64_t.
|
||||
*
|
||||
* On successful conversion 'endp' points to the first character
|
||||
* after conversion is complete.
|
||||
*
|
||||
* 'base': 0 or 2..36
|
||||
*
|
||||
* If base is 0 the base is computed from the string type.
|
||||
*
|
||||
* On error 'endp' points to 'source'.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_string_copy(char *target, size_t size, const char *source);
|
||||
/*
|
||||
* Copy the string pointed to by 'source' to 'target' which is a
|
||||
* pointer to a string of at least 'size' bytes.
|
||||
*
|
||||
* Requires:
|
||||
* 'target' is a pointer to a char[] of at least 'size' bytes.
|
||||
* 'size' an integer > 0.
|
||||
* 'source' == NULL or points to a NUL terminated string.
|
||||
*
|
||||
* Ensures:
|
||||
* If result == ISC_R_SUCCESS
|
||||
* 'target' will be a NUL terminated string of no more
|
||||
* than 'size' bytes (including NUL).
|
||||
*
|
||||
* If result == ISC_R_NOSPACE
|
||||
* 'target' is undefined.
|
||||
*
|
||||
* Returns:
|
||||
* ISC_R_SUCCESS -- 'source' was successfully copied to 'target'.
|
||||
* ISC_R_NOSPACE -- 'source' could not be copied since 'target'
|
||||
* is too small.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_string_copy_truncate(char *target, size_t size, const char *source);
|
||||
/*
|
||||
* Copy the string pointed to by 'source' to 'target' which is a
|
||||
* pointer to a string of at least 'size' bytes.
|
||||
*
|
||||
* Requires:
|
||||
* 'target' is a pointer to a char[] of at least 'size' bytes.
|
||||
* 'size' an integer > 0.
|
||||
* 'source' == NULL or points to a NUL terminated string.
|
||||
*
|
||||
* Ensures:
|
||||
* 'target' will be a NUL terminated string of no more
|
||||
* than 'size' bytes (including NUL).
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_string_append(char *target, size_t size, const char *source);
|
||||
/*
|
||||
* Append the string pointed to by 'source' to 'target' which is a
|
||||
* pointer to a NUL terminated string of at least 'size' bytes.
|
||||
*
|
||||
* Requires:
|
||||
* 'target' is a pointer to a NUL terminated char[] of at
|
||||
* least 'size' bytes.
|
||||
* 'size' an integer > 0.
|
||||
* 'source' == NULL or points to a NUL terminated string.
|
||||
*
|
||||
* Ensures:
|
||||
* If result == ISC_R_SUCCESS
|
||||
* 'target' will be a NUL terminated string of no more
|
||||
* than 'size' bytes (including NUL).
|
||||
*
|
||||
* If result == ISC_R_NOSPACE
|
||||
* 'target' is undefined.
|
||||
*
|
||||
* Returns:
|
||||
* ISC_R_SUCCESS -- 'source' was successfully appended to 'target'.
|
||||
* ISC_R_NOSPACE -- 'source' could not be appended since 'target'
|
||||
* is too small.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_string_append_truncate(char *target, size_t size, const char *source);
|
||||
/*
|
||||
* Append the string pointed to by 'source' to 'target' which is a
|
||||
* pointer to a NUL terminated string of at least 'size' bytes.
|
||||
*
|
||||
* Requires:
|
||||
* 'target' is a pointer to a NUL terminated char[] of at
|
||||
* least 'size' bytes.
|
||||
* 'size' an integer > 0.
|
||||
* 'source' == NULL or points to a NUL terminated string.
|
||||
*
|
||||
* Ensures:
|
||||
* 'target' will be a NUL terminated string of no more
|
||||
* than 'size' bytes (including NUL).
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_string_printf(char *target, size_t size, const char *format, ...)
|
||||
ISC_FORMAT_PRINTF(3, 4);
|
||||
/*
|
||||
* Print 'format' to 'target' which is a pointer to a string of at least
|
||||
* 'size' bytes.
|
||||
*
|
||||
* Requires:
|
||||
* 'target' is a pointer to a char[] of at least 'size' bytes.
|
||||
* 'size' an integer > 0.
|
||||
* 'format' == NULL or points to a NUL terminated string.
|
||||
*
|
||||
* Ensures:
|
||||
* If result == ISC_R_SUCCESS
|
||||
* 'target' will be a NUL terminated string of no more
|
||||
* than 'size' bytes (including NUL).
|
||||
*
|
||||
* If result == ISC_R_NOSPACE
|
||||
* 'target' is undefined.
|
||||
*
|
||||
* Returns:
|
||||
* ISC_R_SUCCESS -- 'format' was successfully printed to 'target'.
|
||||
* ISC_R_NOSPACE -- 'format' could not be printed to 'target' since it
|
||||
* is too small.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_string_printf_truncate(char *target, size_t size, const char *format, ...)
|
||||
ISC_FORMAT_PRINTF(3, 4);
|
||||
/*
|
||||
* Print 'format' to 'target' which is a pointer to a string of at least
|
||||
* 'size' bytes.
|
||||
*
|
||||
* Requires:
|
||||
* 'target' is a pointer to a char[] of at least 'size' bytes.
|
||||
* 'size' an integer > 0.
|
||||
* 'format' == NULL or points to a NUL terminated string.
|
||||
*
|
||||
* Ensures:
|
||||
* 'target' will be a NUL terminated string of no more
|
||||
* than 'size' bytes (including NUL).
|
||||
*/
|
||||
|
||||
|
||||
char *
|
||||
isc_string_regiondup(isc_mem_t *mctx, const isc_region_t *source);
|
||||
/*
|
||||
* Copy the region pointed to by r to a NUL terminated string
|
||||
* allocated from the memory context pointed to by mctx.
|
||||
*
|
||||
* The result should be deallocated using isc_mem_free()
|
||||
*
|
||||
* Requires:
|
||||
* 'mctx' is a point to a valid memory context.
|
||||
* 'source' is a pointer to a valid region.
|
||||
*
|
||||
* Returns:
|
||||
* a pointer to a NUL terminated string or
|
||||
* NULL if memory for the copy could not be allocated
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
isc_tsmemcmp(const void *p1, const void *p2, size_t len);
|
||||
/*
|
||||
* Lexicographic compare 'len' unsigned bytes from 'p1' and 'p2'
|
||||
* like 'memcmp()'.
|
||||
*
|
||||
* This function is safe from timing attacks as it has a runtime that
|
||||
* only depends on 'len' and has no early-out option.
|
||||
*
|
||||
* Use this to check MACs and other material that is security sensitive.
|
||||
*
|
||||
* Returns:
|
||||
* (let x be the byte offset of the first different byte)
|
||||
* -1 if (u_char)p1[x] < (u_char)p2[x]
|
||||
* 1 if (u_char)p1[x] > (u_char)p2[x]
|
||||
* 0 if byte series are equal
|
||||
*/
|
||||
|
||||
char *
|
||||
isc_string_separate(char **stringp, const char *delim);
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDSTRSEP
|
||||
#define strsep isc_string_separate
|
||||
#endif
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDMEMMOVE
|
||||
#define memmove(a,b,c) bcopy(b,a,c)
|
||||
#endif
|
||||
|
||||
size_t
|
||||
isc_string_strlcpy(char *dst, const char *src, size_t size);
|
||||
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDSTRLCPY
|
||||
#define strlcpy isc_string_strlcpy
|
||||
#endif
|
||||
|
||||
|
||||
size_t
|
||||
isc_string_strlcat(char *dst, const char *src, size_t size);
|
||||
|
||||
#ifdef ISC_PLATFORM_NEEDSTRLCAT
|
||||
#define strlcat isc_string_strlcat
|
||||
#endif
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_STRING_H */
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1996-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: symtab.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_SYMTAB_H
|
||||
#define ISC_SYMTAB_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/symtab.h
|
||||
* \brief Provides a simple memory-based symbol table.
|
||||
*
|
||||
* Keys are C strings, and key comparisons are case-insensitive. A type may
|
||||
* be specified when looking up, defining, or undefining. A type value of
|
||||
* 0 means "match any type"; any other value will only match the given
|
||||
* type.
|
||||
*
|
||||
* It's possible that a client will attempt to define a <key, type, value>
|
||||
* tuple when a tuple with the given key and type already exists in the table.
|
||||
* What to do in this case is specified by the client. Possible policies are:
|
||||
*
|
||||
*\li #isc_symexists_reject Disallow the define, returning #ISC_R_EXISTS
|
||||
*\li #isc_symexists_replace Replace the old value with the new. The
|
||||
* undefine action (if provided) will be called
|
||||
* with the old <key, type, value> tuple.
|
||||
*\li #isc_symexists_add Add the new tuple, leaving the old tuple in
|
||||
* the table. Subsequent lookups will retrieve
|
||||
* the most-recently-defined tuple.
|
||||
*
|
||||
* A lookup of a key using type 0 will return the most-recently defined
|
||||
* symbol with that key. An undefine of a key using type 0 will undefine the
|
||||
* most-recently defined symbol with that key. Trying to define a key with
|
||||
* type 0 is illegal.
|
||||
*
|
||||
* The symbol table library does not make a copy the key field, so the
|
||||
* caller must ensure that any key it passes to isc_symtab_define() will not
|
||||
* change until it calls isc_symtab_undefine() or isc_symtab_destroy().
|
||||
*
|
||||
* A user-specified action will be called (if provided) when a symbol is
|
||||
* undefined. It can be used to free memory associated with keys and/or
|
||||
* values.
|
||||
*
|
||||
* A symbol table is implemented as a hash table of lists; the size of the
|
||||
* hash table is set by the 'size' parameter to isc_symtbl_create(). When
|
||||
* the number of entries in the symbol table reaches three quarters of this
|
||||
* value, the hash table is reallocated with size doubled, in order to
|
||||
* optimize lookup performance. This has a negative effect on insertion
|
||||
* performance, which can be mitigated by sizing the table appropriately
|
||||
* when creating it.
|
||||
*
|
||||
* \li MP:
|
||||
* The callers of this module must ensure any required synchronization.
|
||||
*
|
||||
* \li Reliability:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Resources:
|
||||
* TBS
|
||||
*
|
||||
* \li Security:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Standards:
|
||||
* None.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Imports.
|
||||
***/
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/*
|
||||
*** Symbol Tables.
|
||||
***/
|
||||
/*% Symbol table value. */
|
||||
typedef union isc_symvalue {
|
||||
void * as_pointer;
|
||||
const void * as_cpointer;
|
||||
int as_integer;
|
||||
unsigned int as_uinteger;
|
||||
} isc_symvalue_t;
|
||||
|
||||
typedef void (*isc_symtabaction_t)(char *key, unsigned int type,
|
||||
isc_symvalue_t value, void *userarg);
|
||||
/*% Symbol table exists. */
|
||||
typedef enum {
|
||||
isc_symexists_reject = 0, /*%< Disallow the define */
|
||||
isc_symexists_replace = 1, /*%< Replace the old value with the new */
|
||||
isc_symexists_add = 2 /*%< Add the new tuple */
|
||||
} isc_symexists_t;
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*% Create a symbol table. */
|
||||
isc_result_t
|
||||
isc_symtab_create(isc_mem_t *mctx, unsigned int size,
|
||||
isc_symtabaction_t undefine_action, void *undefine_arg,
|
||||
isc_boolean_t case_sensitive, isc_symtab_t **symtabp);
|
||||
|
||||
/*% Destroy a symbol table. */
|
||||
void
|
||||
isc_symtab_destroy(isc_symtab_t **symtabp);
|
||||
|
||||
/*% Lookup a symbol table. */
|
||||
isc_result_t
|
||||
isc_symtab_lookup(isc_symtab_t *symtab, const char *key, unsigned int type,
|
||||
isc_symvalue_t *value);
|
||||
|
||||
/*% Define a symbol table. */
|
||||
isc_result_t
|
||||
isc_symtab_define(isc_symtab_t *symtab, const char *key, unsigned int type,
|
||||
isc_symvalue_t value, isc_symexists_t exists_policy);
|
||||
|
||||
/*% Undefine a symbol table. */
|
||||
isc_result_t
|
||||
isc_symtab_undefine(isc_symtab_t *symtab, const char *key, unsigned int type);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_SYMTAB_H */
|
||||
@@ -0,0 +1,796 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2009-2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2001, 2003 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: task.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_TASK_H
|
||||
#define ISC_TASK_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/task.h
|
||||
* \brief The task system provides a lightweight execution context, which is
|
||||
* basically an event queue.
|
||||
|
||||
* When a task's event queue is non-empty, the
|
||||
* task is runnable. A small work crew of threads, typically one per CPU,
|
||||
* execute runnable tasks by dispatching the events on the tasks' event
|
||||
* queues. Context switching between tasks is fast.
|
||||
*
|
||||
* \li MP:
|
||||
* The module ensures appropriate synchronization of data structures it
|
||||
* creates and manipulates.
|
||||
* The caller must ensure that isc_taskmgr_destroy() is called only
|
||||
* once for a given manager.
|
||||
*
|
||||
* \li Reliability:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Resources:
|
||||
* TBS
|
||||
*
|
||||
* \li Security:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Standards:
|
||||
* None.
|
||||
*
|
||||
* \section purge Purging and Unsending
|
||||
*
|
||||
* Events which have been queued for a task but not delivered may be removed
|
||||
* from the task's event queue by purging or unsending.
|
||||
*
|
||||
* With both types, the caller specifies a matching pattern that selects
|
||||
* events based upon their sender, type, and tag.
|
||||
*
|
||||
* Purging calls isc_event_free() on the matching events.
|
||||
*
|
||||
* Unsending returns a list of events that matched the pattern.
|
||||
* The caller is then responsible for them.
|
||||
*
|
||||
* Consumers of events should purge, not unsend.
|
||||
*
|
||||
* Producers of events often want to remove events when the caller indicates
|
||||
* it is no longer interested in the object, e.g. by canceling a timer.
|
||||
* Sometimes this can be done by purging, but for some event types, the
|
||||
* calls to isc_event_free() cause deadlock because the event free routine
|
||||
* wants to acquire a lock the caller is already holding. Unsending instead
|
||||
* of purging solves this problem. As a general rule, producers should only
|
||||
* unsend events which they have sent.
|
||||
*/
|
||||
|
||||
|
||||
/***
|
||||
*** Imports.
|
||||
***/
|
||||
|
||||
#include <isc/eventclass.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/stdtime.h>
|
||||
#include <isc/types.h>
|
||||
#include <isc/xml.h>
|
||||
|
||||
#define ISC_TASKEVENT_FIRSTEVENT (ISC_EVENTCLASS_TASK + 0)
|
||||
#define ISC_TASKEVENT_SHUTDOWN (ISC_EVENTCLASS_TASK + 1)
|
||||
#define ISC_TASKEVENT_TEST (ISC_EVENTCLASS_TASK + 1)
|
||||
#define ISC_TASKEVENT_LASTEVENT (ISC_EVENTCLASS_TASK + 65535)
|
||||
|
||||
/*****
|
||||
***** Tasks.
|
||||
*****/
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/***
|
||||
*** Types
|
||||
***/
|
||||
|
||||
typedef enum {
|
||||
isc_taskmgrmode_normal = 0,
|
||||
isc_taskmgrmode_privileged
|
||||
} isc_taskmgrmode_t;
|
||||
|
||||
/*% Task and task manager methods */
|
||||
typedef struct isc_taskmgrmethods {
|
||||
void (*destroy)(isc_taskmgr_t **managerp);
|
||||
void (*setmode)(isc_taskmgr_t *manager,
|
||||
isc_taskmgrmode_t mode);
|
||||
isc_taskmgrmode_t (*mode)(isc_taskmgr_t *manager);
|
||||
isc_result_t (*taskcreate)(isc_taskmgr_t *manager,
|
||||
unsigned int quantum,
|
||||
isc_task_t **taskp);
|
||||
} isc_taskmgrmethods_t;
|
||||
|
||||
typedef struct isc_taskmethods {
|
||||
void (*attach)(isc_task_t *source, isc_task_t **targetp);
|
||||
void (*detach)(isc_task_t **taskp);
|
||||
void (*destroy)(isc_task_t **taskp);
|
||||
void (*send)(isc_task_t *task, isc_event_t **eventp);
|
||||
void (*sendanddetach)(isc_task_t **taskp, isc_event_t **eventp);
|
||||
unsigned int (*unsend)(isc_task_t *task, void *sender, isc_eventtype_t type,
|
||||
void *tag, isc_eventlist_t *events);
|
||||
isc_result_t (*onshutdown)(isc_task_t *task, isc_taskaction_t action,
|
||||
const void *arg);
|
||||
void (*shutdown)(isc_task_t *task);
|
||||
void (*setname)(isc_task_t *task, const char *name, void *tag);
|
||||
unsigned int (*purgeevents)(isc_task_t *task, void *sender,
|
||||
isc_eventtype_t type, void *tag);
|
||||
unsigned int (*purgerange)(isc_task_t *task, void *sender,
|
||||
isc_eventtype_t first, isc_eventtype_t last,
|
||||
void *tag);
|
||||
isc_result_t (*beginexclusive)(isc_task_t *task);
|
||||
void (*endexclusive)(isc_task_t *task);
|
||||
void (*setprivilege)(isc_task_t *task, isc_boolean_t priv);
|
||||
isc_boolean_t (*privilege)(isc_task_t *task);
|
||||
} isc_taskmethods_t;
|
||||
|
||||
/*%
|
||||
* This structure is actually just the common prefix of a task manager
|
||||
* object implementation's version of an isc_taskmgr_t.
|
||||
* \brief
|
||||
* Direct use of this structure by clients is forbidden. task implementations
|
||||
* may change the structure. 'magic' must be ISCAPI_TASKMGR_MAGIC for any
|
||||
* of the isc_task_ routines to work. task implementations must maintain
|
||||
* all task invariants.
|
||||
*/
|
||||
struct isc_taskmgr {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_taskmgrmethods_t *methods;
|
||||
};
|
||||
|
||||
#define ISCAPI_TASKMGR_MAGIC ISC_MAGIC('A','t','m','g')
|
||||
#define ISCAPI_TASKMGR_VALID(m) ((m) != NULL && \
|
||||
(m)->magic == ISCAPI_TASKMGR_MAGIC)
|
||||
|
||||
/*%
|
||||
* This is the common prefix of a task object. The same note as
|
||||
* that for the taskmgr structure applies.
|
||||
*/
|
||||
struct isc_task {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_taskmethods_t *methods;
|
||||
};
|
||||
|
||||
#define ISCAPI_TASK_MAGIC ISC_MAGIC('A','t','s','t')
|
||||
#define ISCAPI_TASK_VALID(s) ((s) != NULL && \
|
||||
(s)->magic == ISCAPI_TASK_MAGIC)
|
||||
|
||||
isc_result_t
|
||||
isc_task_create(isc_taskmgr_t *manager, unsigned int quantum,
|
||||
isc_task_t **taskp);
|
||||
/*%<
|
||||
* Create a task.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li If 'quantum' is non-zero, then only that many events can be dispatched
|
||||
* before the task must yield to other tasks waiting to execute. If
|
||||
* quantum is zero, then the default quantum of the task manager will
|
||||
* be used.
|
||||
*
|
||||
*\li The 'quantum' option may be removed from isc_task_create() in the
|
||||
* future. If this happens, isc_task_getquantum() and
|
||||
* isc_task_setquantum() will be provided.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'manager' is a valid task manager.
|
||||
*
|
||||
*\li taskp != NULL && *taskp == NULL
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li On success, '*taskp' is bound to the new task.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_NOMEMORY
|
||||
*\li #ISC_R_UNEXPECTED
|
||||
*\li #ISC_R_SHUTTINGDOWN
|
||||
*/
|
||||
|
||||
void
|
||||
isc_task_attach(isc_task_t *source, isc_task_t **targetp);
|
||||
/*%<
|
||||
* Attach *targetp to source.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'source' is a valid task.
|
||||
*
|
||||
*\li 'targetp' points to a NULL isc_task_t *.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li *targetp is attached to source.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_task_detach(isc_task_t **taskp);
|
||||
/*%<
|
||||
* Detach *taskp from its task.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li '*taskp' is a valid task.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li *taskp is NULL.
|
||||
*
|
||||
*\li If '*taskp' is the last reference to the task, the task is idle (has
|
||||
* an empty event queue), and has not been shutdown, the task will be
|
||||
* shutdown.
|
||||
*
|
||||
*\li If '*taskp' is the last reference to the task and
|
||||
* the task has been shutdown,
|
||||
* all resources used by the task will be freed.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_task_send(isc_task_t *task, isc_event_t **eventp);
|
||||
/*%<
|
||||
* Send '*event' to 'task'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'task' is a valid task.
|
||||
*\li eventp != NULL && *eventp != NULL.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li *eventp == NULL.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp);
|
||||
/*%<
|
||||
* Send '*event' to '*taskp' and then detach '*taskp' from its
|
||||
* task.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li '*taskp' is a valid task.
|
||||
*\li eventp != NULL && *eventp != NULL.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li *eventp == NULL.
|
||||
*
|
||||
*\li *taskp == NULL.
|
||||
*
|
||||
*\li If '*taskp' is the last reference to the task, the task is
|
||||
* idle (has an empty event queue), and has not been shutdown,
|
||||
* the task will be shutdown.
|
||||
*
|
||||
*\li If '*taskp' is the last reference to the task and
|
||||
* the task has been shutdown,
|
||||
* all resources used by the task will be freed.
|
||||
*/
|
||||
|
||||
|
||||
unsigned int
|
||||
isc_task_purgerange(isc_task_t *task, void *sender, isc_eventtype_t first,
|
||||
isc_eventtype_t last, void *tag);
|
||||
/*%<
|
||||
* Purge events from a task's event queue.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'task' is a valid task.
|
||||
*
|
||||
*\li last >= first
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li Events in the event queue of 'task' whose sender is 'sender', whose
|
||||
* type is >= first and <= last, and whose tag is 'tag' will be purged,
|
||||
* unless they are marked as unpurgable.
|
||||
*
|
||||
*\li A sender of NULL will match any sender. A NULL tag matches any
|
||||
* tag.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li The number of events purged.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_task_purge(isc_task_t *task, void *sender, isc_eventtype_t type,
|
||||
void *tag);
|
||||
/*%<
|
||||
* Purge events from a task's event queue.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li This function is equivalent to
|
||||
*
|
||||
*\code
|
||||
* isc_task_purgerange(task, sender, type, type, tag);
|
||||
*\endcode
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'task' is a valid task.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li Events in the event queue of 'task' whose sender is 'sender', whose
|
||||
* type is 'type', and whose tag is 'tag' will be purged, unless they
|
||||
* are marked as unpurgable.
|
||||
*
|
||||
*\li A sender of NULL will match any sender. A NULL tag matches any
|
||||
* tag.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li The number of events purged.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_task_purgeevent(isc_task_t *task, isc_event_t *event);
|
||||
/*%<
|
||||
* Purge 'event' from a task's event queue.
|
||||
*
|
||||
* XXXRTH: WARNING: This method may be removed before beta.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li If 'event' is on the task's event queue, it will be purged,
|
||||
* unless it is marked as unpurgeable. 'event' does not have to be
|
||||
* on the task's event queue; in fact, it can even be an invalid
|
||||
* pointer. Purging only occurs if the event is actually on the task's
|
||||
* event queue.
|
||||
*
|
||||
* \li Purging never changes the state of the task.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'task' is a valid task.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li 'event' is not in the event queue for 'task'.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li #ISC_TRUE The event was purged.
|
||||
*\li #ISC_FALSE The event was not in the event queue,
|
||||
* or was marked unpurgeable.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_task_unsendrange(isc_task_t *task, void *sender, isc_eventtype_t first,
|
||||
isc_eventtype_t last, void *tag, isc_eventlist_t *events);
|
||||
/*%<
|
||||
* Remove events from a task's event queue.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'task' is a valid task.
|
||||
*
|
||||
*\li last >= first.
|
||||
*
|
||||
*\li *events is a valid list.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li Events in the event queue of 'task' whose sender is 'sender', whose
|
||||
* type is >= first and <= last, and whose tag is 'tag' will be dequeued
|
||||
* and appended to *events.
|
||||
*
|
||||
*\li A sender of NULL will match any sender. A NULL tag matches any
|
||||
* tag.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li The number of events unsent.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
isc_task_unsend(isc_task_t *task, void *sender, isc_eventtype_t type,
|
||||
void *tag, isc_eventlist_t *events);
|
||||
/*%<
|
||||
* Remove events from a task's event queue.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li This function is equivalent to
|
||||
*
|
||||
*\code
|
||||
* isc_task_unsendrange(task, sender, type, type, tag, events);
|
||||
*\endcode
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'task' is a valid task.
|
||||
*
|
||||
*\li *events is a valid list.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li Events in the event queue of 'task' whose sender is 'sender', whose
|
||||
* type is 'type', and whose tag is 'tag' will be dequeued and appended
|
||||
* to *events.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li The number of events unsent.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_task_onshutdown(isc_task_t *task, isc_taskaction_t action,
|
||||
const void *arg);
|
||||
/*%<
|
||||
* Send a shutdown event with action 'action' and argument 'arg' when
|
||||
* 'task' is shutdown.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li Shutdown events are posted in LIFO order.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'task' is a valid task.
|
||||
*
|
||||
*\li 'action' is a valid task action.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li When the task is shutdown, shutdown events requested with
|
||||
* isc_task_onshutdown() will be appended to the task's event queue.
|
||||
*
|
||||
|
||||
* Returns:
|
||||
*
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_NOMEMORY
|
||||
*\li #ISC_R_TASKSHUTTINGDOWN Task is shutting down.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_task_shutdown(isc_task_t *task);
|
||||
/*%<
|
||||
* Shutdown 'task'.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li Shutting down a task causes any shutdown events requested with
|
||||
* isc_task_onshutdown() to be posted (in LIFO order). The task
|
||||
* moves into a "shutting down" mode which prevents further calls
|
||||
* to isc_task_onshutdown().
|
||||
*
|
||||
*\li Trying to shutdown a task that has already been shutdown has no
|
||||
* effect.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'task' is a valid task.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li Any shutdown events requested with isc_task_onshutdown() have been
|
||||
* posted (in LIFO order).
|
||||
*/
|
||||
|
||||
void
|
||||
isc_task_destroy(isc_task_t **taskp);
|
||||
/*%<
|
||||
* Destroy '*taskp'.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li This call is equivalent to:
|
||||
*
|
||||
*\code
|
||||
* isc_task_shutdown(*taskp);
|
||||
* isc_task_detach(taskp);
|
||||
*\endcode
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
* '*taskp' is a valid task.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li Any shutdown events requested with isc_task_onshutdown() have been
|
||||
* posted (in LIFO order).
|
||||
*
|
||||
*\li *taskp == NULL
|
||||
*
|
||||
*\li If '*taskp' is the last reference to the task,
|
||||
* all resources used by the task will be freed.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_task_setname(isc_task_t *task, const char *name, void *tag);
|
||||
/*%<
|
||||
* Name 'task'.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li Only the first 15 characters of 'name' will be copied.
|
||||
*
|
||||
*\li Naming a task is currently only useful for debugging purposes.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'task' is a valid task.
|
||||
*/
|
||||
|
||||
const char *
|
||||
isc_task_getname(isc_task_t *task);
|
||||
/*%<
|
||||
* Get the name of 'task', as previously set using isc_task_setname().
|
||||
*
|
||||
* Notes:
|
||||
*\li This function is for debugging purposes only.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'task' is a valid task.
|
||||
*
|
||||
* Returns:
|
||||
*\li A non-NULL pointer to a null-terminated string.
|
||||
* If the task has not been named, the string is
|
||||
* empty.
|
||||
*
|
||||
*/
|
||||
|
||||
void *
|
||||
isc_task_gettag(isc_task_t *task);
|
||||
/*%<
|
||||
* Get the tag value for 'task', as previously set using isc_task_settag().
|
||||
*
|
||||
* Notes:
|
||||
*\li This function is for debugging purposes only.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'task' is a valid task.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_task_beginexclusive(isc_task_t *task);
|
||||
/*%<
|
||||
* Request exclusive access for 'task', which must be the calling
|
||||
* task. Waits for any other concurrently executing tasks to finish their
|
||||
* current event, and prevents any new events from executing in any of the
|
||||
* tasks sharing a task manager with 'task'.
|
||||
*
|
||||
* The exclusive access must be relinquished by calling
|
||||
* isc_task_endexclusive() before returning from the current event handler.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'task' is the calling task.
|
||||
*
|
||||
* Returns:
|
||||
*\li #ISC_R_SUCCESS The current task now has exclusive access.
|
||||
*\li #ISC_R_LOCKBUSY Another task has already requested exclusive
|
||||
* access.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_task_endexclusive(isc_task_t *task);
|
||||
/*%<
|
||||
* Relinquish the exclusive access obtained by isc_task_beginexclusive(),
|
||||
* allowing other tasks to execute.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'task' is the calling task, and has obtained
|
||||
* exclusive access by calling isc_task_spl().
|
||||
*/
|
||||
|
||||
void
|
||||
isc_task_getcurrenttime(isc_task_t *task, isc_stdtime_t *t);
|
||||
/*%<
|
||||
* Provide the most recent timestamp on the task. The timestamp is considered
|
||||
* as the "current time" in the second-order granularity.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'task' is a valid task.
|
||||
*\li 't' is a valid non NULL pointer.
|
||||
*
|
||||
* Ensures:
|
||||
*\li '*t' has the "current time".
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_task_exiting(isc_task_t *t);
|
||||
/*%<
|
||||
* Returns ISC_TRUE if the task is in the process of shutting down,
|
||||
* ISC_FALSE otherwise.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'task' is a valid task.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_task_setprivilege(isc_task_t *task, isc_boolean_t priv);
|
||||
/*%<
|
||||
* Set or unset the task's "privileged" flag depending on the value of
|
||||
* 'priv'.
|
||||
*
|
||||
* Under normal circumstances this flag has no effect on the task behavior,
|
||||
* but when the task manager has been set to privileged exeuction mode via
|
||||
* isc_taskmgr_setmode(), only tasks with the flag set will be executed,
|
||||
* and all other tasks will wait until they're done. Once all privileged
|
||||
* tasks have finished executing, the task manager will automatically
|
||||
* return to normal execution mode and nonprivileged task can resume.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'task' is a valid task.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_task_privilege(isc_task_t *task);
|
||||
/*%<
|
||||
* Returns the current value of the task's privilege flag.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'task' is a valid task.
|
||||
*/
|
||||
|
||||
/*****
|
||||
***** Task Manager.
|
||||
*****/
|
||||
|
||||
isc_result_t
|
||||
isc_taskmgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
|
||||
unsigned int workers, unsigned int default_quantum,
|
||||
isc_taskmgr_t **managerp);
|
||||
isc_result_t
|
||||
isc_taskmgr_create(isc_mem_t *mctx, unsigned int workers,
|
||||
unsigned int default_quantum, isc_taskmgr_t **managerp);
|
||||
/*%<
|
||||
* Create a new task manager. isc_taskmgr_createinctx() also associates
|
||||
* the new manager with the specified application context.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li 'workers' in the number of worker threads to create. In general,
|
||||
* the value should be close to the number of processors in the system.
|
||||
* The 'workers' value is advisory only. An attempt will be made to
|
||||
* create 'workers' threads, but if at least one thread creation
|
||||
* succeeds, isc_taskmgr_create() may return ISC_R_SUCCESS.
|
||||
*
|
||||
*\li If 'default_quantum' is non-zero, then it will be used as the default
|
||||
* quantum value when tasks are created. If zero, then an implementation
|
||||
* defined default quantum will be used.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'mctx' is a valid memory context.
|
||||
*
|
||||
*\li workers > 0
|
||||
*
|
||||
*\li managerp != NULL && *managerp == NULL
|
||||
*
|
||||
*\li 'actx' is a valid application context (for createinctx()).
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li On success, '*managerp' will be attached to the newly created task
|
||||
* manager.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_NOMEMORY
|
||||
*\li #ISC_R_NOTHREADS No threads could be created.
|
||||
*\li #ISC_R_UNEXPECTED An unexpected error occurred.
|
||||
*\li #ISC_R_SHUTTINGDOWN The non-threaded, shared, task
|
||||
* manager shutting down.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_taskmgr_setmode(isc_taskmgr_t *manager, isc_taskmgrmode_t mode);
|
||||
|
||||
isc_taskmgrmode_t
|
||||
isc_taskmgr_mode(isc_taskmgr_t *manager);
|
||||
/*%<
|
||||
* Set/get the current operating mode of the task manager. Valid modes are:
|
||||
*
|
||||
*\li isc_taskmgrmode_normal
|
||||
*\li isc_taskmgrmode_privileged
|
||||
*
|
||||
* In privileged execution mode, only tasks that have had the "privilege"
|
||||
* flag set via isc_task_setprivilege() can be executed. When all such
|
||||
* tasks are complete, the manager automatically returns to normal mode
|
||||
* and proceeds with running non-privileged ready tasks. This means it is
|
||||
* necessary to have at least one privileged task waiting on the ready
|
||||
* queue *before* setting the manager into privileged execution mode,
|
||||
* which in turn means the task which calls this function should be in
|
||||
* task-exclusive mode when it does so.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'manager' is a valid task manager.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_taskmgr_destroy(isc_taskmgr_t **managerp);
|
||||
/*%<
|
||||
* Destroy '*managerp'.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li Calling isc_taskmgr_destroy() will shutdown all tasks managed by
|
||||
* *managerp that haven't already been shutdown. The call will block
|
||||
* until all tasks have entered the done state.
|
||||
*
|
||||
*\li isc_taskmgr_destroy() must not be called by a task event action,
|
||||
* because it would block forever waiting for the event action to
|
||||
* complete. An event action that wants to cause task manager shutdown
|
||||
* should request some non-event action thread of execution to do the
|
||||
* shutdown, e.g. by signaling a condition variable or using
|
||||
* isc_app_shutdown().
|
||||
*
|
||||
*\li Task manager references are not reference counted, so the caller
|
||||
* must ensure that no attempt will be made to use the manager after
|
||||
* isc_taskmgr_destroy() returns.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li '*managerp' is a valid task manager.
|
||||
*
|
||||
*\li isc_taskmgr_destroy() has not be called previously on '*managerp'.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li All resources used by the task manager, and any tasks it managed,
|
||||
* have been freed.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_LIBXML2
|
||||
|
||||
void
|
||||
isc_taskmgr_renderxml(isc_taskmgr_t *mgr, xmlTextWriterPtr writer);
|
||||
|
||||
#endif
|
||||
|
||||
/*%<
|
||||
* See isc_taskmgr_create() above.
|
||||
*/
|
||||
typedef isc_result_t
|
||||
(*isc_taskmgrcreatefunc_t)(isc_mem_t *mctx, unsigned int workers,
|
||||
unsigned int default_quantum,
|
||||
isc_taskmgr_t **managerp);
|
||||
|
||||
isc_result_t
|
||||
isc_task_register(isc_taskmgrcreatefunc_t createfunc);
|
||||
/*%<
|
||||
* Register a new task management implementation and add it to the list of
|
||||
* supported implementations. This function must be called when a different
|
||||
* event library is used than the one contained in the ISC library.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc__task_register(void);
|
||||
/*%<
|
||||
* A short cut function that specifies the task management module in the ISC
|
||||
* library for isc_task_register(). An application that uses the ISC library
|
||||
* usually do not have to care about this function: it would call
|
||||
* isc_lib_register(), which internally calls this function.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_TASK_H */
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: taskpool.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_TASKPOOL_H
|
||||
#define ISC_TASKPOOL_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/taskpool.h
|
||||
* \brief A task pool is a mechanism for sharing a small number of tasks
|
||||
* among a large number of objects such that each object is
|
||||
* assigned a unique task, but each task may be shared by several
|
||||
* objects.
|
||||
*
|
||||
* Task pools are used to let objects that can exist in large
|
||||
* numbers (e.g., zones) use tasks for synchronization without
|
||||
* the memory overhead and unfair scheduling competition that
|
||||
* could result from creating a separate task for each object.
|
||||
*/
|
||||
|
||||
|
||||
/***
|
||||
*** Imports.
|
||||
***/
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/task.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*****
|
||||
***** Types.
|
||||
*****/
|
||||
|
||||
typedef struct isc_taskpool isc_taskpool_t;
|
||||
|
||||
/*****
|
||||
***** Functions.
|
||||
*****/
|
||||
|
||||
isc_result_t
|
||||
isc_taskpool_create(isc_taskmgr_t *tmgr, isc_mem_t *mctx,
|
||||
unsigned int ntasks, unsigned int quantum,
|
||||
isc_taskpool_t **poolp);
|
||||
/*%<
|
||||
* Create a task pool of "ntasks" tasks, each with quantum
|
||||
* "quantum".
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'tmgr' is a valid task manager.
|
||||
*
|
||||
*\li 'mctx' is a valid memory context.
|
||||
*
|
||||
*\li poolp != NULL && *poolp == NULL
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li On success, '*taskp' points to the new task pool.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li #ISC_R_SUCCESS
|
||||
*\li #ISC_R_NOMEMORY
|
||||
*\li #ISC_R_UNEXPECTED
|
||||
*/
|
||||
|
||||
void
|
||||
isc_taskpool_gettask(isc_taskpool_t *pool, isc_task_t **targetp);
|
||||
/*%<
|
||||
* Attach to a task from the pool. Currently the next task is chosen
|
||||
* from the pool at random. (This may be changed in the future to
|
||||
* something that guaratees balance.)
|
||||
*/
|
||||
|
||||
int
|
||||
isc_taskpool_size(isc_taskpool_t *pool);
|
||||
/*%<
|
||||
* Returns the number of tasks in the task pool 'pool'.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_taskpool_expand(isc_taskpool_t **sourcep, unsigned int size,
|
||||
isc_taskpool_t **targetp);
|
||||
|
||||
/*%<
|
||||
* If 'size' is larger than the number of tasks in the pool pointed to by
|
||||
* 'sourcep', then a new taskpool of size 'size' is allocated, the existing
|
||||
* tasks from are moved into it, additional tasks are created to bring the
|
||||
* total number up to 'size', and the resulting pool is attached to
|
||||
* 'targetp'.
|
||||
*
|
||||
* If 'size' is less than or equal to the tasks in pool 'source', then
|
||||
* 'sourcep' is attached to 'targetp' without any other action being taken.
|
||||
*
|
||||
* In either case, 'sourcep' is detached.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
* \li 'sourcep' is not NULL and '*source' is not NULL
|
||||
* \li 'targetp' is not NULL and '*source' is NULL
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
* \li On success, '*targetp' points to a valid task pool.
|
||||
* \li On success, '*sourcep' points to NULL.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
* \li #ISC_R_SUCCESS
|
||||
* \li #ISC_R_NOMEMORY
|
||||
*/
|
||||
|
||||
void
|
||||
isc_taskpool_destroy(isc_taskpool_t **poolp);
|
||||
/*%<
|
||||
* Destroy a task pool. The tasks in the pool are detached but not
|
||||
* shut down.
|
||||
*
|
||||
* Requires:
|
||||
* \li '*poolp' is a valid task pool.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_taskpool_setprivilege(isc_taskpool_t *pool, isc_boolean_t priv);
|
||||
/*%<
|
||||
* Set the privilege flag on all tasks in 'pool' to 'priv'. If 'priv' is
|
||||
* true, then when the task manager is set into privileged mode, only
|
||||
* tasks wihin this pool will be able to execute. (Note: It is important
|
||||
* to turn the pool tasks' privilege back off before the last task finishes
|
||||
* executing.)
|
||||
*
|
||||
* Requires:
|
||||
* \li 'pool' is a valid task pool.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_TASKPOOL_H */
|
||||
@@ -0,0 +1,334 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: time.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_TIME_H
|
||||
#define ISC_TIME_H 1
|
||||
|
||||
/*! \file */
|
||||
|
||||
#include <isc/lang.h>
|
||||
#include <isc/types.h>
|
||||
|
||||
/***
|
||||
*** Intervals
|
||||
***/
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
* The contents of this structure are private, and MUST NOT be accessed
|
||||
* directly by callers.
|
||||
*
|
||||
* The contents are exposed only to allow callers to avoid dynamic allocation.
|
||||
*/
|
||||
struct isc_interval {
|
||||
unsigned int seconds;
|
||||
unsigned int nanoseconds;
|
||||
};
|
||||
|
||||
extern isc_interval_t *isc_interval_zero;
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
void
|
||||
isc_interval_set(isc_interval_t *i,
|
||||
unsigned int seconds, unsigned int nanoseconds);
|
||||
/*%<
|
||||
* Set 'i' to a value representing an interval of 'seconds' seconds and
|
||||
* 'nanoseconds' nanoseconds, suitable for use in isc_time_add() and
|
||||
* isc_time_subtract().
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 't' is a valid pointer.
|
||||
*\li nanoseconds < 1000000000.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_interval_iszero(const isc_interval_t *i);
|
||||
/*%<
|
||||
* Returns ISC_TRUE iff. 'i' is the zero interval.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'i' is a valid pointer.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** Absolute Times
|
||||
***/
|
||||
|
||||
/*%
|
||||
* The contents of this structure are private, and MUST NOT be accessed
|
||||
* directly by callers.
|
||||
*
|
||||
* The contents are exposed only to allow callers to avoid dynamic allocation.
|
||||
*/
|
||||
|
||||
struct isc_time {
|
||||
unsigned int seconds;
|
||||
unsigned int nanoseconds;
|
||||
};
|
||||
|
||||
extern isc_time_t *isc_time_epoch;
|
||||
|
||||
void
|
||||
isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds);
|
||||
/*%<
|
||||
* Set 't' to a value which represents the given number of seconds and
|
||||
* nanoseconds since 00:00:00 January 1, 1970, UTC.
|
||||
*
|
||||
* Notes:
|
||||
*\li The Unix version of this call is equivalent to:
|
||||
*\code
|
||||
* isc_time_settoepoch(t);
|
||||
* isc_interval_set(i, seconds, nanoseconds);
|
||||
* isc_time_add(t, i, t);
|
||||
*\endcode
|
||||
*
|
||||
* Requires:
|
||||
*\li 't' is a valid pointer.
|
||||
*\li nanoseconds < 1000000000.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_time_settoepoch(isc_time_t *t);
|
||||
/*%<
|
||||
* Set 't' to the time of the epoch.
|
||||
*
|
||||
* Notes:
|
||||
*\li The date of the epoch is platform-dependent.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 't' is a valid pointer.
|
||||
*/
|
||||
|
||||
isc_boolean_t
|
||||
isc_time_isepoch(const isc_time_t *t);
|
||||
/*%<
|
||||
* Returns ISC_TRUE iff. 't' is the epoch ("time zero").
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 't' is a valid pointer.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_time_now(isc_time_t *t);
|
||||
/*%<
|
||||
* Set 't' to the current absolute time.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 't' is a valid pointer.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li Success
|
||||
*\li Unexpected error
|
||||
* Getting the time from the system failed.
|
||||
*\li Out of range
|
||||
* The time from the system is too large to be represented
|
||||
* in the current definition of isc_time_t.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i);
|
||||
/*%<
|
||||
* Set *t to the current absolute time + i.
|
||||
*
|
||||
* Note:
|
||||
*\li This call is equivalent to:
|
||||
*
|
||||
*\code
|
||||
* isc_time_now(t);
|
||||
* isc_time_add(t, i, t);
|
||||
*\endcode
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 't' and 'i' are valid pointers.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li Success
|
||||
*\li Unexpected error
|
||||
* Getting the time from the system failed.
|
||||
*\li Out of range
|
||||
* The interval added to the time from the system is too large to
|
||||
* be represented in the current definition of isc_time_t.
|
||||
*/
|
||||
|
||||
int
|
||||
isc_time_compare(const isc_time_t *t1, const isc_time_t *t2);
|
||||
/*%<
|
||||
* Compare the times referenced by 't1' and 't2'
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 't1' and 't2' are valid pointers.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li -1 t1 < t2 (comparing times, not pointers)
|
||||
*\li 0 t1 = t2
|
||||
*\li 1 t1 > t2
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_time_add(const isc_time_t *t, const isc_interval_t *i, isc_time_t *result);
|
||||
/*%<
|
||||
* Add 'i' to 't', storing the result in 'result'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 't', 'i', and 'result' are valid pointers.
|
||||
*
|
||||
* Returns:
|
||||
*\li Success
|
||||
*\li Out of range
|
||||
* The interval added to the time is too large to
|
||||
* be represented in the current definition of isc_time_t.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
|
||||
isc_time_t *result);
|
||||
/*%<
|
||||
* Subtract 'i' from 't', storing the result in 'result'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 't', 'i', and 'result' are valid pointers.
|
||||
*
|
||||
* Returns:
|
||||
*\li Success
|
||||
*\li Out of range
|
||||
* The interval is larger than the time since the epoch.
|
||||
*/
|
||||
|
||||
isc_uint64_t
|
||||
isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2);
|
||||
/*%<
|
||||
* Find the difference in microseconds between time t1 and time t2.
|
||||
* t2 is the subtrahend of t1; ie, difference = t1 - t2.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 't1' and 't2' are valid pointers.
|
||||
*
|
||||
* Returns:
|
||||
*\li The difference of t1 - t2, or 0 if t1 <= t2.
|
||||
*/
|
||||
|
||||
isc_uint32_t
|
||||
isc_time_seconds(const isc_time_t *t);
|
||||
/*%<
|
||||
* Return the number of seconds since the epoch stored in a time structure.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 't' is a valid pointer.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_time_secondsastimet(const isc_time_t *t, time_t *secondsp);
|
||||
/*%<
|
||||
* Ensure the number of seconds in an isc_time_t is representable by a time_t.
|
||||
*
|
||||
* Notes:
|
||||
*\li The number of seconds stored in an isc_time_t might be larger
|
||||
* than the number of seconds a time_t is able to handle. Since
|
||||
* time_t is mostly opaque according to the ANSI/ISO standard
|
||||
* (essentially, all you can be sure of is that it is an arithmetic type,
|
||||
* not even necessarily integral), it can be tricky to ensure that
|
||||
* the isc_time_t is in the range a time_t can handle. Use this
|
||||
* function in place of isc_time_seconds() any time you need to set a
|
||||
* time_t from an isc_time_t.
|
||||
*
|
||||
* Requires:
|
||||
*\li 't' is a valid pointer.
|
||||
*
|
||||
* Returns:
|
||||
*\li Success
|
||||
*\li Out of range
|
||||
*/
|
||||
|
||||
isc_uint32_t
|
||||
isc_time_nanoseconds(const isc_time_t *t);
|
||||
/*%<
|
||||
* Return the number of nanoseconds stored in a time structure.
|
||||
*
|
||||
* Notes:
|
||||
*\li This is the number of nanoseconds in excess of the number
|
||||
* of seconds since the epoch; it will always be less than one
|
||||
* full second.
|
||||
*
|
||||
* Requires:
|
||||
*\li 't' is a valid pointer.
|
||||
*
|
||||
* Ensures:
|
||||
*\li The returned value is less than 1*10^9.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len);
|
||||
/*%<
|
||||
* Format the time 't' into the buffer 'buf' of length 'len',
|
||||
* using a format like "30-Aug-2000 04:06:47.997" and the local time zone.
|
||||
* If the text does not fit in the buffer, the result is indeterminate,
|
||||
* but is always guaranteed to be null terminated.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'len' > 0
|
||||
*\li 'buf' points to an array of at least len chars
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
isc_time_formathttptimestamp(const isc_time_t *t, char *buf, unsigned int len);
|
||||
/*%<
|
||||
* Format the time 't' into the buffer 'buf' of length 'len',
|
||||
* using a format like "Mon, 30 Aug 2000 04:06:47 GMT"
|
||||
* If the text does not fit in the buffer, the result is indeterminate,
|
||||
* but is always guaranteed to be null terminated.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'len' > 0
|
||||
*\li 'buf' points to an array of at least len chars
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len);
|
||||
/*%<
|
||||
* Format the time 't' into the buffer 'buf' of length 'len',
|
||||
* using the ISO8601 format: "yyyy-mm-ddThh:mm:ssZ"
|
||||
* If the text does not fit in the buffer, the result is indeterminate,
|
||||
* but is always guaranteed to be null terminated.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'len' > 0
|
||||
*\li 'buf' points to an array of at least len chars
|
||||
*
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_TIME_H */
|
||||
@@ -0,0 +1,431 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2002 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: timer.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_TIMER_H
|
||||
#define ISC_TIMER_H 1
|
||||
|
||||
/*****
|
||||
***** Module Info
|
||||
*****/
|
||||
|
||||
/*! \file isc/timer.h
|
||||
* \brief Provides timers which are event sources in the task system.
|
||||
*
|
||||
* Three types of timers are supported:
|
||||
*
|
||||
*\li 'ticker' timers generate a periodic tick event.
|
||||
*
|
||||
*\li 'once' timers generate an idle timeout event if they are idle for too
|
||||
* long, and generate a life timeout event if their lifetime expires.
|
||||
* They are used to implement both (possibly expiring) idle timers and
|
||||
* 'one-shot' timers.
|
||||
*
|
||||
*\li 'limited' timers generate a periodic tick event until they reach
|
||||
* their lifetime when they generate a life timeout event.
|
||||
*
|
||||
*\li 'inactive' timers generate no events.
|
||||
*
|
||||
* Timers can change type. It is typical to create a timer as
|
||||
* an 'inactive' timer and then change it into a 'ticker' or
|
||||
* 'once' timer.
|
||||
*
|
||||
*\li MP:
|
||||
* The module ensures appropriate synchronization of data structures it
|
||||
* creates and manipulates.
|
||||
* Clients of this module must not be holding a timer's task's lock when
|
||||
* making a call that affects that timer. Failure to follow this rule
|
||||
* can result in deadlock.
|
||||
* The caller must ensure that isc_timermgr_destroy() is called only
|
||||
* once for a given manager.
|
||||
*
|
||||
* \li Reliability:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Resources:
|
||||
* TBS
|
||||
*
|
||||
* \li Security:
|
||||
* No anticipated impact.
|
||||
*
|
||||
* \li Standards:
|
||||
* None.
|
||||
*/
|
||||
|
||||
|
||||
/***
|
||||
*** Imports
|
||||
***/
|
||||
|
||||
#include <isc/types.h>
|
||||
#include <isc/event.h>
|
||||
#include <isc/eventclass.h>
|
||||
#include <isc/lang.h>
|
||||
#include <isc/time.h>
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/***
|
||||
*** Types
|
||||
***/
|
||||
|
||||
/*% Timer Type */
|
||||
typedef enum {
|
||||
isc_timertype_ticker = 0, /*%< Ticker */
|
||||
isc_timertype_once = 1, /*%< Once */
|
||||
isc_timertype_limited = 2, /*%< Limited */
|
||||
isc_timertype_inactive = 3 /*%< Inactive */
|
||||
} isc_timertype_t;
|
||||
|
||||
typedef struct isc_timerevent {
|
||||
struct isc_event common;
|
||||
isc_time_t due;
|
||||
} isc_timerevent_t;
|
||||
|
||||
#define ISC_TIMEREVENT_FIRSTEVENT (ISC_EVENTCLASS_TIMER + 0)
|
||||
#define ISC_TIMEREVENT_TICK (ISC_EVENTCLASS_TIMER + 1)
|
||||
#define ISC_TIMEREVENT_IDLE (ISC_EVENTCLASS_TIMER + 2)
|
||||
#define ISC_TIMEREVENT_LIFE (ISC_EVENTCLASS_TIMER + 3)
|
||||
#define ISC_TIMEREVENT_LASTEVENT (ISC_EVENTCLASS_TIMER + 65535)
|
||||
|
||||
/*% Timer and timer manager methods */
|
||||
typedef struct {
|
||||
void (*destroy)(isc_timermgr_t **managerp);
|
||||
isc_result_t (*timercreate)(isc_timermgr_t *manager,
|
||||
isc_timertype_t type,
|
||||
isc_time_t *expires,
|
||||
isc_interval_t *interval,
|
||||
isc_task_t *task,
|
||||
isc_taskaction_t action,
|
||||
const void *arg,
|
||||
isc_timer_t **timerp);
|
||||
} isc_timermgrmethods_t;
|
||||
|
||||
typedef struct {
|
||||
void (*attach)(isc_timer_t *timer, isc_timer_t **timerp);
|
||||
void (*detach)(isc_timer_t **timerp);
|
||||
isc_result_t (*reset)(isc_timer_t *timer, isc_timertype_t type,
|
||||
isc_time_t *expires, isc_interval_t *interval,
|
||||
isc_boolean_t purge);
|
||||
isc_result_t (*touch)(isc_timer_t *timer);
|
||||
} isc_timermethods_t;
|
||||
|
||||
/*%
|
||||
* This structure is actually just the common prefix of a timer manager
|
||||
* object implementation's version of an isc_timermgr_t.
|
||||
* \brief
|
||||
* Direct use of this structure by clients is forbidden. timer implementations
|
||||
* may change the structure. 'magic' must be ISCAPI_TIMERMGR_MAGIC for any
|
||||
* of the isc_timer_ routines to work. timer implementations must maintain
|
||||
* all timer invariants.
|
||||
*/
|
||||
struct isc_timermgr {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_timermgrmethods_t *methods;
|
||||
};
|
||||
|
||||
#define ISCAPI_TIMERMGR_MAGIC ISC_MAGIC('A','t','m','g')
|
||||
#define ISCAPI_TIMERMGR_VALID(m) ((m) != NULL && \
|
||||
(m)->magic == ISCAPI_TIMERMGR_MAGIC)
|
||||
|
||||
/*%
|
||||
* This is the common prefix of a timer object. The same note as
|
||||
* that for the timermgr structure applies.
|
||||
*/
|
||||
struct isc_timer {
|
||||
unsigned int impmagic;
|
||||
unsigned int magic;
|
||||
isc_timermethods_t *methods;
|
||||
};
|
||||
|
||||
#define ISCAPI_TIMER_MAGIC ISC_MAGIC('A','t','m','r')
|
||||
#define ISCAPI_TIMER_VALID(s) ((s) != NULL && \
|
||||
(s)->magic == ISCAPI_TIMER_MAGIC)
|
||||
|
||||
/***
|
||||
*** Timer and Timer Manager Functions
|
||||
***
|
||||
*** Note: all Ensures conditions apply only if the result is success for
|
||||
*** those functions which return an isc_result_t.
|
||||
***/
|
||||
|
||||
isc_result_t
|
||||
isc_timer_create(isc_timermgr_t *manager,
|
||||
isc_timertype_t type,
|
||||
isc_time_t *expires,
|
||||
isc_interval_t *interval,
|
||||
isc_task_t *task,
|
||||
isc_taskaction_t action,
|
||||
const void *arg,
|
||||
isc_timer_t **timerp);
|
||||
/*%<
|
||||
* Create a new 'type' timer managed by 'manager'. The timers parameters
|
||||
* are specified by 'expires' and 'interval'. Events will be posted to
|
||||
* 'task' and when dispatched 'action' will be called with 'arg' as the
|
||||
* arg value. The new timer is returned in 'timerp'.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li For ticker timers, the timer will generate a 'tick' event every
|
||||
* 'interval' seconds. The value of 'expires' is ignored.
|
||||
*
|
||||
*\li For once timers, 'expires' specifies the time when a life timeout
|
||||
* event should be generated. If 'expires' is 0 (the epoch), then no life
|
||||
* timeout will be generated. 'interval' specifies how long the timer
|
||||
* can be idle before it generates an idle timeout. If 0, then no
|
||||
* idle timeout will be generated.
|
||||
*
|
||||
*\li If 'expires' is NULL, the epoch will be used.
|
||||
*
|
||||
* If 'interval' is NULL, the zero interval will be used.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'manager' is a valid manager
|
||||
*
|
||||
*\li 'task' is a valid task
|
||||
*
|
||||
*\li 'action' is a valid action
|
||||
*
|
||||
*\li 'expires' points to a valid time, or is NULL.
|
||||
*
|
||||
*\li 'interval' points to a valid interval, or is NULL.
|
||||
*
|
||||
*\li type == isc_timertype_inactive ||
|
||||
* ('expires' and 'interval' are not both 0)
|
||||
*
|
||||
*\li 'timerp' is a valid pointer, and *timerp == NULL
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li '*timerp' is attached to the newly created timer
|
||||
*
|
||||
*\li The timer is attached to the task
|
||||
*
|
||||
*\li An idle timeout will not be generated until at least Now + the
|
||||
* timer's interval if 'timer' is a once timer with a non-zero
|
||||
* interval.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li Success
|
||||
*\li No memory
|
||||
*\li Unexpected error
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_timer_reset(isc_timer_t *timer,
|
||||
isc_timertype_t type,
|
||||
isc_time_t *expires,
|
||||
isc_interval_t *interval,
|
||||
isc_boolean_t purge);
|
||||
/*%<
|
||||
* Change the timer's type, expires, and interval values to the given
|
||||
* values. If 'purge' is TRUE, any pending events from this timer
|
||||
* are purged from its task's event queue.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li If 'expires' is NULL, the epoch will be used.
|
||||
*
|
||||
*\li If 'interval' is NULL, the zero interval will be used.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'timer' is a valid timer
|
||||
*
|
||||
*\li The same requirements that isc_timer_create() imposes on 'type',
|
||||
* 'expires' and 'interval' apply.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li An idle timeout will not be generated until at least Now + the
|
||||
* timer's interval if 'timer' is a once timer with a non-zero
|
||||
* interval.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li Success
|
||||
*\li No memory
|
||||
*\li Unexpected error
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_timer_touch(isc_timer_t *timer);
|
||||
/*%<
|
||||
* Set the last-touched time of 'timer' to the current time.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'timer' is a valid once timer.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li An idle timeout will not be generated until at least Now + the
|
||||
* timer's interval if 'timer' is a once timer with a non-zero
|
||||
* interval.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li Success
|
||||
*\li Unexpected error
|
||||
*/
|
||||
|
||||
void
|
||||
isc_timer_attach(isc_timer_t *timer, isc_timer_t **timerp);
|
||||
/*%<
|
||||
* Attach *timerp to timer.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'timer' is a valid timer.
|
||||
*
|
||||
*\li 'timerp' points to a NULL timer.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li *timerp is attached to timer.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_timer_detach(isc_timer_t **timerp);
|
||||
/*%<
|
||||
* Detach *timerp from its timer.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'timerp' points to a valid timer.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li *timerp is NULL.
|
||||
*
|
||||
*\li If '*timerp' is the last reference to the timer,
|
||||
* then:
|
||||
*
|
||||
*\code
|
||||
* The timer will be shutdown
|
||||
*
|
||||
* The timer will detach from its task
|
||||
*
|
||||
* All resources used by the timer have been freed
|
||||
*
|
||||
* Any events already posted by the timer will be purged.
|
||||
* Therefore, if isc_timer_detach() is called in the context
|
||||
* of the timer's task, it is guaranteed that no more
|
||||
* timer event callbacks will run after the call.
|
||||
*\endcode
|
||||
*/
|
||||
|
||||
isc_timertype_t
|
||||
isc_timer_gettype(isc_timer_t *timer);
|
||||
/*%<
|
||||
* Return the timer type.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'timer' to be a valid timer.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_timermgr_createinctx(isc_mem_t *mctx, isc_appctx_t *actx,
|
||||
isc_timermgr_t **managerp);
|
||||
|
||||
isc_result_t
|
||||
isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp);
|
||||
/*%<
|
||||
* Create a timer manager. isc_timermgr_createinctx() also associates
|
||||
* the new manager with the specified application context.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li All memory will be allocated in memory context 'mctx'.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li 'mctx' is a valid memory context.
|
||||
*
|
||||
*\li 'managerp' points to a NULL isc_timermgr_t.
|
||||
*
|
||||
*\li 'actx' is a valid application context (for createinctx()).
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li '*managerp' is a valid isc_timermgr_t.
|
||||
*
|
||||
* Returns:
|
||||
*
|
||||
*\li Success
|
||||
*\li No memory
|
||||
*\li Unexpected error
|
||||
*/
|
||||
|
||||
void
|
||||
isc_timermgr_destroy(isc_timermgr_t **managerp);
|
||||
/*%<
|
||||
* Destroy a timer manager.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
*\li This routine blocks until there are no timers left in the manager,
|
||||
* so if the caller holds any timer references using the manager, it
|
||||
* must detach them before calling isc_timermgr_destroy() or it will
|
||||
* block forever.
|
||||
*
|
||||
* Requires:
|
||||
*
|
||||
*\li '*managerp' is a valid isc_timermgr_t.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
*\li *managerp == NULL
|
||||
*
|
||||
*\li All resources used by the manager have been freed.
|
||||
*/
|
||||
|
||||
void isc_timermgr_poke(isc_timermgr_t *m);
|
||||
|
||||
#ifdef USE_TIMERIMPREGISTER
|
||||
/*%<
|
||||
* See isc_timermgr_create() above.
|
||||
*/
|
||||
typedef isc_result_t
|
||||
(*isc_timermgrcreatefunc_t)(isc_mem_t *mctx, isc_timermgr_t **managerp);
|
||||
|
||||
isc_result_t
|
||||
isc__timer_register(void);
|
||||
/*%<
|
||||
* Register a new timer management implementation and add it to the list of
|
||||
* supported implementations. This function must be called when a different
|
||||
* event library is used than the one contained in the ISC library.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_timer_register(isc_timermgrcreatefunc_t createfunc);
|
||||
/*%<
|
||||
* A short cut function that specifies the timer management module in the ISC
|
||||
* library for isc_timer_register(). An application that uses the ISC library
|
||||
* usually do not have to care about this function: it would call
|
||||
* isc_lib_register(), which internally calls this function.
|
||||
*/
|
||||
#endif /* USE_TIMERIMPREGISTER */
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* ISC_TIMER_H */
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2009, 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1999-2003 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: types.h,v 1.2.10.2 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_TYPES_H
|
||||
#define ISC_TYPES_H 1
|
||||
|
||||
#include <isc/bind9.h>
|
||||
#include <isc/namespace.h>
|
||||
|
||||
/*! \file isc/types.h
|
||||
* \brief
|
||||
* OS-specific types, from the OS-specific include directories.
|
||||
*/
|
||||
#include <isc/int.h>
|
||||
#include <isc/offset.h>
|
||||
|
||||
/*
|
||||
* XXXDCL should isc_boolean_t be moved here, requiring an explicit include
|
||||
* of <isc/boolean.h> when ISC_TRUE/ISC_FALSE/ISC_TF() are desired?
|
||||
*/
|
||||
#include <isc/boolean.h>
|
||||
/*
|
||||
* XXXDCL This is just for ISC_LIST and ISC_LINK, but gets all of the other
|
||||
* list macros too.
|
||||
*/
|
||||
#include <isc/isc_list.h>
|
||||
|
||||
/* Core Types. Alphabetized by defined type. */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct isc_appctx isc_appctx_t; /*%< Application context */
|
||||
typedef struct isc_backtrace_symmap isc_backtrace_symmap_t; /*%< Symbol Table Entry */
|
||||
typedef struct isc_bitstring isc_bitstring_t; /*%< Bitstring */
|
||||
typedef struct isc_buffer isc_buffer_t; /*%< Buffer */
|
||||
typedef ISC_LIST(isc_buffer_t) isc_bufferlist_t; /*%< Buffer List */
|
||||
typedef struct isc_constregion isc_constregion_t; /*%< Const region */
|
||||
typedef struct isc_consttextregion isc_consttextregion_t; /*%< Const Text Region */
|
||||
typedef struct isc_entropy isc_entropy_t; /*%< Entropy */
|
||||
typedef struct isc_entropysource isc_entropysource_t; /*%< Entropy Source */
|
||||
typedef struct isc_event isc_event_t; /*%< Event */
|
||||
typedef ISC_LIST(isc_event_t) isc_eventlist_t; /*%< Event List */
|
||||
typedef unsigned int isc_eventtype_t; /*%< Event Type */
|
||||
typedef isc_uint32_t isc_fsaccess_t; /*%< FS Access */
|
||||
typedef struct isc_hash isc_hash_t; /*%< Hash */
|
||||
typedef struct isc_httpd isc_httpd_t; /*%< HTTP client */
|
||||
typedef void (isc_httpdfree_t)(isc_buffer_t *, void *); /*%< HTTP free function */
|
||||
typedef struct isc_httpdmgr isc_httpdmgr_t; /*%< HTTP manager */
|
||||
typedef struct isc_httpdurl isc_httpdurl_t; /*%< HTTP URL */
|
||||
typedef void (isc_httpdondestroy_t)(void *); /*%< Callback on destroying httpd */
|
||||
typedef struct isc_interface isc_interface_t; /*%< Interface */
|
||||
typedef struct isc_interfaceiter isc_interfaceiter_t; /*%< Interface Iterator */
|
||||
typedef struct isc_interval isc_interval_t; /*%< Interval */
|
||||
typedef struct isc_lex isc_lex_t; /*%< Lex */
|
||||
typedef struct isc_log isc_log_t; /*%< Log */
|
||||
typedef struct isc_logcategory isc_logcategory_t; /*%< Log Category */
|
||||
typedef struct isc_logconfig isc_logconfig_t; /*%< Log Configuration */
|
||||
typedef struct isc_logmodule isc_logmodule_t; /*%< Log Module */
|
||||
typedef struct isc_mem isc_mem_t; /*%< Memory */
|
||||
typedef struct isc_mempool isc_mempool_t; /*%< Memory Pool */
|
||||
typedef struct isc_msgcat isc_msgcat_t; /*%< Message Catalog */
|
||||
typedef struct isc_ondestroy isc_ondestroy_t; /*%< On Destroy */
|
||||
typedef struct isc_netaddr isc_netaddr_t; /*%< Net Address */
|
||||
typedef struct isc_portset isc_portset_t; /*%< Port Set */
|
||||
typedef struct isc_quota isc_quota_t; /*%< Quota */
|
||||
typedef struct isc_random isc_random_t; /*%< Random */
|
||||
typedef struct isc_ratelimiter isc_ratelimiter_t; /*%< Rate Limiter */
|
||||
typedef struct isc_region isc_region_t; /*%< Region */
|
||||
typedef isc_uint64_t isc_resourcevalue_t; /*%< Resource Value */
|
||||
typedef unsigned int isc_result_t; /*%< Result */
|
||||
typedef struct isc_rwlock isc_rwlock_t; /*%< Read Write Lock */
|
||||
typedef struct isc_sockaddr isc_sockaddr_t; /*%< Socket Address */
|
||||
typedef struct isc_socket isc_socket_t; /*%< Socket */
|
||||
typedef struct isc_socketevent isc_socketevent_t; /*%< Socket Event */
|
||||
typedef struct isc_socketmgr isc_socketmgr_t; /*%< Socket Manager */
|
||||
typedef struct isc_stats isc_stats_t; /*%< Statistics */
|
||||
typedef int isc_statscounter_t; /*%< Statistics Counter */
|
||||
typedef struct isc_symtab isc_symtab_t; /*%< Symbol Table */
|
||||
typedef struct isc_task isc_task_t; /*%< Task */
|
||||
typedef ISC_LIST(isc_task_t) isc_tasklist_t; /*%< Task List */
|
||||
typedef struct isc_taskmgr isc_taskmgr_t; /*%< Task Manager */
|
||||
typedef struct isc_textregion isc_textregion_t; /*%< Text Region */
|
||||
typedef struct isc_time isc_time_t; /*%< Time */
|
||||
typedef struct isc_timer isc_timer_t; /*%< Timer */
|
||||
typedef struct isc_timermgr isc_timermgr_t; /*%< Timer Manager */
|
||||
|
||||
typedef void (*isc_taskaction_t)(isc_task_t *, isc_event_t *);
|
||||
typedef int (*isc_sockfdwatch_t)(isc_task_t *, isc_socket_t *, void *, int);
|
||||
|
||||
/* The following cannot be listed alphabetically due to forward reference */
|
||||
typedef isc_result_t (isc_httpdaction_t)(const char *url,
|
||||
const char *querystring,
|
||||
void *arg,
|
||||
unsigned int *retcode,
|
||||
const char **retmsg,
|
||||
const char **mimetype,
|
||||
isc_buffer_t *body,
|
||||
isc_httpdfree_t **freecb,
|
||||
void **freecb_args);
|
||||
typedef isc_boolean_t (isc_httpdclientok_t)(const isc_sockaddr_t *, void *);
|
||||
|
||||
/*% Resource */
|
||||
typedef enum {
|
||||
isc_resource_coresize = 1,
|
||||
isc_resource_cputime,
|
||||
isc_resource_datasize,
|
||||
isc_resource_filesize,
|
||||
isc_resource_lockedmemory,
|
||||
isc_resource_openfiles,
|
||||
isc_resource_processes,
|
||||
isc_resource_residentsize,
|
||||
isc_resource_stacksize
|
||||
} isc_resource_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* ISC_TYPES_H */
|
||||
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007, 2010-2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 1998-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: util.h,v 1.2.10.1 2015-03-31 09:17:14 lyang3 Exp $ */
|
||||
|
||||
#ifndef ISC_UTIL_H
|
||||
#define ISC_UTIL_H 1
|
||||
|
||||
/*! \file isc/util.h
|
||||
* NOTE:
|
||||
*
|
||||
* This file is not to be included from any <isc/???.h> (or other) library
|
||||
* files.
|
||||
*
|
||||
* \brief
|
||||
* Including this file puts several macros in your name space that are
|
||||
* not protected (as all the other ISC functions/macros do) by prepending
|
||||
* ISC_ or isc_ to the name.
|
||||
*/
|
||||
|
||||
/***
|
||||
*** General Macros.
|
||||
***/
|
||||
|
||||
/*%
|
||||
* Use this to hide unused function arguments.
|
||||
* \code
|
||||
* int
|
||||
* foo(char *bar)
|
||||
* {
|
||||
* UNUSED(bar);
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
/*%
|
||||
* The opposite: silent warnings about stored values which are never read.
|
||||
*/
|
||||
#define POST(x) (void)(x)
|
||||
|
||||
#define ISC_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define ISC_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
/*%
|
||||
* Use this to remove the const qualifier of a variable to assign it to
|
||||
* a non-const variable or pass it as a non-const function argument ...
|
||||
* but only when you are sure it won't then be changed!
|
||||
* This is necessary to sometimes shut up some compilers
|
||||
* (as with gcc -Wcast-qual) when there is just no other good way to avoid the
|
||||
* situation.
|
||||
*/
|
||||
#define DE_CONST(konst, var) \
|
||||
do { \
|
||||
union { const void *k; void *v; } _u; \
|
||||
_u.k = konst; \
|
||||
var = _u.v; \
|
||||
} while (0)
|
||||
|
||||
/*%
|
||||
* Use this in translation units that would otherwise be empty, to
|
||||
* suppress compiler warnings.
|
||||
*/
|
||||
#define EMPTY_TRANSLATION_UNIT extern void exit(int);
|
||||
|
||||
/*%
|
||||
* We use macros instead of calling the routines directly because
|
||||
* the capital letters make the locking stand out.
|
||||
* We RUNTIME_CHECK for success since in general there's no way
|
||||
* for us to continue if they fail.
|
||||
*/
|
||||
|
||||
#ifdef ISC_UTIL_TRACEON
|
||||
#define ISC_UTIL_TRACE(a) a
|
||||
#include <stdio.h> /* Required for fprintf/stderr when tracing. */
|
||||
#include <isc/msgs.h> /* Required for isc_msgcat when tracing. */
|
||||
#else
|
||||
#define ISC_UTIL_TRACE(a)
|
||||
#endif
|
||||
|
||||
#include <isc/result.h> /* Contractual promise. */
|
||||
|
||||
#define LOCK(lp) do { \
|
||||
ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
|
||||
ISC_MSG_LOCKING, "LOCKING"), \
|
||||
(lp), __FILE__, __LINE__)); \
|
||||
RUNTIME_CHECK(isc_mutex_lock((lp)) == ISC_R_SUCCESS); \
|
||||
ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
|
||||
ISC_MSG_LOCKED, "LOCKED"), \
|
||||
(lp), __FILE__, __LINE__)); \
|
||||
} while (0)
|
||||
#define UNLOCK(lp) do { \
|
||||
RUNTIME_CHECK(isc_mutex_unlock((lp)) == ISC_R_SUCCESS); \
|
||||
ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
|
||||
ISC_MSG_UNLOCKED, "UNLOCKED"), \
|
||||
(lp), __FILE__, __LINE__)); \
|
||||
} while (0)
|
||||
#define ISLOCKED(lp) (1)
|
||||
#define DESTROYLOCK(lp) \
|
||||
RUNTIME_CHECK(isc_mutex_destroy((lp)) == ISC_R_SUCCESS)
|
||||
|
||||
|
||||
#define BROADCAST(cvp) do { \
|
||||
ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
|
||||
ISC_MSG_BROADCAST, "BROADCAST"),\
|
||||
(cvp), __FILE__, __LINE__)); \
|
||||
RUNTIME_CHECK(isc_condition_broadcast((cvp)) == ISC_R_SUCCESS); \
|
||||
} while (0)
|
||||
#define SIGNAL(cvp) do { \
|
||||
ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
|
||||
ISC_MSG_SIGNAL, "SIGNAL"), \
|
||||
(cvp), __FILE__, __LINE__)); \
|
||||
RUNTIME_CHECK(isc_condition_signal((cvp)) == ISC_R_SUCCESS); \
|
||||
} while (0)
|
||||
#define WAIT(cvp, lp) do { \
|
||||
ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %p %s %d\n", \
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
|
||||
ISC_MSG_UTILWAIT, "WAIT"), \
|
||||
(cvp), \
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
|
||||
ISC_MSG_LOCK, "LOCK"), \
|
||||
(lp), __FILE__, __LINE__)); \
|
||||
RUNTIME_CHECK(isc_condition_wait((cvp), (lp)) == ISC_R_SUCCESS); \
|
||||
ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %p %s %d\n", \
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
|
||||
ISC_MSG_WAITED, "WAITED"), \
|
||||
(cvp), \
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
|
||||
ISC_MSG_LOCKED, "LOCKED"), \
|
||||
(lp), __FILE__, __LINE__)); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* isc_condition_waituntil can return ISC_R_TIMEDOUT, so we
|
||||
* don't RUNTIME_CHECK the result.
|
||||
*
|
||||
* XXX Also, can't really debug this then...
|
||||
*/
|
||||
|
||||
#define WAITUNTIL(cvp, lp, tp) \
|
||||
isc_condition_waituntil((cvp), (lp), (tp))
|
||||
|
||||
#define RWLOCK(lp, t) do { \
|
||||
ISC_UTIL_TRACE(fprintf(stderr, "%s %p, %d %s %d\n", \
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
|
||||
ISC_MSG_RWLOCK, "RWLOCK"), \
|
||||
(lp), (t), __FILE__, __LINE__)); \
|
||||
RUNTIME_CHECK(isc_rwlock_lock((lp), (t)) == ISC_R_SUCCESS); \
|
||||
ISC_UTIL_TRACE(fprintf(stderr, "%s %p, %d %s %d\n", \
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
|
||||
ISC_MSG_RWLOCKED, "RWLOCKED"), \
|
||||
(lp), (t), __FILE__, __LINE__)); \
|
||||
} while (0)
|
||||
#define RWUNLOCK(lp, t) do { \
|
||||
ISC_UTIL_TRACE(fprintf(stderr, "%s %p, %d %s %d\n", \
|
||||
isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
|
||||
ISC_MSG_RWUNLOCK, "RWUNLOCK"), \
|
||||
(lp), (t), __FILE__, __LINE__)); \
|
||||
RUNTIME_CHECK(isc_rwlock_unlock((lp), (t)) == ISC_R_SUCCESS); \
|
||||
} while (0)
|
||||
|
||||
#define DESTROYMUTEXBLOCK(bp, n) \
|
||||
RUNTIME_CHECK(isc_mutexblock_destroy((bp), (n)) == ISC_R_SUCCESS)
|
||||
|
||||
/*
|
||||
* List Macros.
|
||||
*/
|
||||
#include <isc/isc_list.h> /* Contractual promise. */
|
||||
|
||||
#define LIST(type) ISC_LIST(type)
|
||||
#define INIT_LIST(type) ISC_LIST_INIT(type)
|
||||
#define LINK(type) ISC_LINK(type)
|
||||
#define INIT_LINK(elt, link) ISC_LINK_INIT(elt, link)
|
||||
#define HEAD(list) ISC_LIST_HEAD(list)
|
||||
#define TAIL(list) ISC_LIST_TAIL(list)
|
||||
#define EMPTY(list) ISC_LIST_EMPTY(list)
|
||||
#define PREV(elt, link) ISC_LIST_PREV(elt, link)
|
||||
#define NEXT(elt, link) ISC_LIST_NEXT(elt, link)
|
||||
#define APPEND(list, elt, link) ISC_LIST_APPEND(list, elt, link)
|
||||
#define PREPEND(list, elt, link) ISC_LIST_PREPEND(list, elt, link)
|
||||
#define UNLINK(list, elt, link) ISC_LIST_UNLINK(list, elt, link)
|
||||
#define ENQUEUE(list, elt, link) ISC_LIST_APPEND(list, elt, link)
|
||||
#define DEQUEUE(list, elt, link) ISC_LIST_UNLINK(list, elt, link)
|
||||
#define INSERTBEFORE(li, b, e, ln) ISC_LIST_INSERTBEFORE(li, b, e, ln)
|
||||
#define INSERTAFTER(li, a, e, ln) ISC_LIST_INSERTAFTER(li, a, e, ln)
|
||||
#define APPENDLIST(list1, list2, link) ISC_LIST_APPENDLIST(list1, list2, link)
|
||||
|
||||
/*
|
||||
* Assertions
|
||||
*/
|
||||
#include <isc/assertions.h> /* Contractual promise. */
|
||||
|
||||
/*% Require Assertion */
|
||||
#define REQUIRE(e) ISC_REQUIRE(e)
|
||||
/*% Ensure Assertion */
|
||||
#define ENSURE(e) ISC_ENSURE(e)
|
||||
/*% Insist Assertion */
|
||||
#define INSIST(e) ISC_INSIST(e)
|
||||
/*% Invariant Assertion */
|
||||
#define INVARIANT(e) ISC_INVARIANT(e)
|
||||
|
||||
/*
|
||||
* Errors
|
||||
*/
|
||||
#include <isc/isc_error.h> /* Contractual promise. */
|
||||
|
||||
/*% Unexpected Error */
|
||||
#define UNEXPECTED_ERROR isc_error_unexpected
|
||||
/*% Fatal Error */
|
||||
#define FATAL_ERROR isc_error_fatal
|
||||
/*% Runtime Check */
|
||||
#define RUNTIME_CHECK(cond) ISC_ERROR_RUNTIMECHECK(cond)
|
||||
|
||||
/*%
|
||||
* Time
|
||||
*/
|
||||
#define TIME_NOW(tp) RUNTIME_CHECK(isc_time_now((tp)) == ISC_R_SUCCESS)
|
||||
|
||||
#endif /* ISC_UTIL_H */
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (C) 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC 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: version.h,v 1.1.2.1 2015-04-01 02:13:20 lyang3 Exp $ */
|
||||
|
||||
/*! \file isc/version.h */
|
||||
|
||||
#include <isc/platform.h>
|
||||
|
||||
LIBISC_EXTERNAL_DATA extern const char isc_version[];
|
||||
|
||||
LIBISC_EXTERNAL_DATA extern const unsigned int isc_libinterface;
|
||||
LIBISC_EXTERNAL_DATA extern const unsigned int isc_librevision;
|
||||
LIBISC_EXTERNAL_DATA extern const unsigned int isc_libage;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user