ntp: import ntp-4.2.8p16

Security:	NtpBug3767, NtpBug3808, NtpBug3807 (CVE-2023-26555)
This commit is contained in:
Cy Schubert 2023-05-11 11:17:53 -07:00
parent 3914721463
commit 26fd3d5616
885 changed files with 82175 additions and 82752 deletions

201
COPYRIGHT
View File

@ -3,7 +3,7 @@ This file is automatically generated from html/copyright.html
jpg "Clone me," says Dolly sheepishly.
Last update: 4-Feb-2020 23:47 UTC
Last update: 2-Mar-2023 05:21 UTC
__________________________________________________________________
The following copyright notice applies to all files collectively called
@ -28,11 +28,11 @@ This file is automatically generated from html/copyright.html
* *
***********************************************************************
Content starting in 2011 from Harlan Stenn, Danny Mayer, and Martin
Burnicki is:
Content starting in 2011 from Harlan Stenn, Juergen Perlinger, Dave
Hart, Danny Mayer, Martin Burnicki, and possibly others is:
***********************************************************************
* *
* Copyright (c) Network Time Foundation 2011-2020 *
* Copyright (c) Network Time Foundation 2011-2023 *
* *
* All Rights Reserved *
* *
@ -85,73 +85,75 @@ This file is automatically generated from html/copyright.html
13. [14]Steve Clift <clift@ml.csiro.au> OMEGA clock driver
14. [15]Casey Crellin <casey@csc.co.za> vxWorks (Tornado) port and help
with target configuration
15. [16]Sven Dietrich <sven_dietrich@trimble.com> Palisade reference
15. [16]Philippe De Muyter <phdm@macqel.be> Wharton reference clock
driver, sysV68 and AIX modifications.
16. [17]Sven Dietrich <sven_dietrich@trimble.com> Palisade reference
clock driver, NT adj. residuals, integrated Greg's Winnt port.
16. [17]John A. Dundas III <dundas@salt.jpl.nasa.gov> Apple A/UX port
17. [18]Torsten Duwe <duwe@immd4.informatik.uni-erlangen.de> Linux port
18. [19]Dennis Ferguson <dennis@mrbill.canet.ca> foundation code for
17. [18]John A. Dundas III <dundas@salt.jpl.nasa.gov> Apple A/UX port
18. [19]Torsten Duwe <duwe@immd4.informatik.uni-erlangen.de> Linux port
19. [20]Dennis Ferguson <dennis@mrbill.canet.ca> foundation code for
NTP Version 2 as specified in RFC-1119
19. [20]John Hay <jhay@icomtek.csir.co.za> IPv6 support and testing
20. [21]Dave Hart <davehart@davehart.com> General maintenance, Windows
port interpolation rewrite
21. [22]Claas Hilbrecht <neoclock4x@linum.com> NeoClock4X clock driver
22. [23]Glenn Hollinger <glenn@herald.usask.ca> GOES clock driver
23. [24]Mike Iglesias <iglesias@uci.edu> DEC Alpha port
24. [25]Jim Jagielski <jim@jagubox.gsfc.nasa.gov> A/UX port
25. [26]Jeff Johnson <jbj@chatham.usdesign.com> massive prototyping
20. [21]John Hay <jhay@icomtek.csir.co.za> IPv6 support and testing
21. [22]Dave Hart <davehart@gmail.com> General maintenance, IPv6
cleanup, Windows PPSAPI
22. [23]Claas Hilbrecht <neoclock4x@linum.com> NeoClock4X clock driver
23. [24]Glenn Hollinger <glenn@herald.usask.ca> GOES clock driver
24. [25]Mike Iglesias <iglesias@uci.edu> DEC Alpha port
25. [26]Jim Jagielski <jim@jagubox.gsfc.nasa.gov> A/UX port
26. [27]Jeff Johnson <jbj@chatham.usdesign.com> massive prototyping
overhaul
26. [27]Hans Lambermont <Hans.Lambermont@nl.origin-it.com> or
[28]<H.Lambermont@chello.nl> ntpsweep
27. [29]Poul-Henning Kamp <phk@FreeBSD.ORG> Oncore driver (Original
27. [28]Hans Lambermont <Hans.Lambermont@nl.origin-it.com> or
[29]<H.Lambermont@chello.nl> ntpsweep
28. [30]Poul-Henning Kamp <phk@FreeBSD.ORG> Oncore driver (Original
author)
28. [30]Frank Kardel [31]<kardel (at) ntp (dot) org> PARSE <GENERIC>
29. [31]Frank Kardel [32]<kardel (at) ntp (dot) org> PARSE <GENERIC>
(driver 14 reference clocks), STREAMS modules for PARSE, support
scripts, syslog cleanup, dynamic interface handling
29. [32]Johannes Maximilian Kuehn <kuehn@ntp.org> Rewrote sntp to
30. [33]Johannes Maximilian Kuehn <kuehn@ntp.org> Rewrote sntp to
comply with NTPv4 specification, ntpq saveconfig
30. [33]William L. Jones <jones@hermes.chpc.utexas.edu> RS/6000 AIX
31. [34]William L. Jones <jones@hermes.chpc.utexas.edu> RS/6000 AIX
modifications, HPUX modifications
31. [34]Dave Katz <dkatz@cisco.com> RS/6000 AIX port
32. [35]Craig Leres <leres@ee.lbl.gov> 4.4BSD port, ppsclock, Magnavox
32. [35]Dave Katz <dkatz@cisco.com> RS/6000 AIX port
33. [36]Craig Leres <leres@ee.lbl.gov> 4.4BSD port, ppsclock, Magnavox
GPS clock driver
33. [36]George Lindholm <lindholm@ucs.ubc.ca> SunOS 5.1 port
34. [37]Louis A. Mamakos <louie@ni.umd.edu> MD5-based authentication
35. [38]Lars H. Mathiesen <thorinn@diku.dk> adaptation of foundation
34. [37]George Lindholm <lindholm@ucs.ubc.ca> SunOS 5.1 port
35. [38]Louis A. Mamakos <louie@ni.umd.edu> MD5-based authentication
36. [39]Lars H. Mathiesen <thorinn@diku.dk> adaptation of foundation
code for Version 3 as specified in RFC-1305
36. [39]Danny Mayer <mayer@ntp.org>Network I/O, Windows Port, Code
37. [40]Danny Mayer <mayer@ntp.org>Network I/O, Windows Port, Code
Maintenance
37. [40]David L. Mills <mills@udel.edu> Version 4 foundation, precision
38. [41]David L. Mills <mills@udel.edu> Version 4 foundation, precision
kernel; clock drivers: 1, 3, 4, 6, 7, 11, 13, 18, 19, 22, 36
38. [41]Wolfgang Moeller <moeller@gwdgv1.dnet.gwdg.de> VMS port
39. [42]Jeffrey Mogul <mogul@pa.dec.com> ntptrace utility
40. [43]Tom Moore <tmoore@fievel.daytonoh.ncr.com> i386 svr4 port
41. [44]Kamal A Mostafa <kamal@whence.com> SCO OpenServer port
42. [45]Derek Mulcahy <derek@toybox.demon.co.uk> and [46]Damon
39. [42]Wolfgang Moeller <moeller@gwdgv1.dnet.gwdg.de> VMS port
40. [43]Jeffrey Mogul <mogul@pa.dec.com> ntptrace utility
41. [44]Tom Moore <tmoore@fievel.daytonoh.ncr.com> i386 svr4 port
42. [45]Kamal A Mostafa <kamal@whence.com> SCO OpenServer port
43. [46]Derek Mulcahy <derek@toybox.demon.co.uk> and [47]Damon
Hart-Davis <d@hd.org> ARCRON MSF clock driver
43. [47]Rob Neal <neal@ntp.org> Bancomm refclock and config/parse code
44. [48]Rob Neal <neal@ntp.org> Bancomm refclock and config/parse code
maintenance
44. [48]Rainer Pruy <Rainer.Pruy@informatik.uni-erlangen.de>
45. [49]Rainer Pruy <Rainer.Pruy@informatik.uni-erlangen.de>
monitoring/trap scripts, statistics file handling
45. [49]Dirce Richards <dirce@zk3.dec.com> Digital UNIX V4.0 port
46. [50]Wilfredo Sánchez <wsanchez@apple.com> added support for NetInfo
47. [51]Nick Sayer <mrapple@quack.kfu.com> SunOS streams modules
48. [52]Jack Sasportas <jack@innovativeinternet.com> Saved a Lot of
46. [50]Dirce Richards <dirce@zk3.dec.com> Digital UNIX V4.0 port
47. [51]Wilfredo Sánchez <wsanchez@apple.com> added support for NetInfo
48. [52]Nick Sayer <mrapple@quack.kfu.com> SunOS streams modules
49. [53]Jack Sasportas <jack@innovativeinternet.com> Saved a Lot of
space on the stuff in the html/pic/ subdirectory
49. [53]Ray Schnitzler <schnitz@unipress.com> Unixware1 port
50. [54]Michael Shields <shields@tembel.org> USNO clock driver
51. [55]Jeff Steinman <jss@pebbles.jpl.nasa.gov> Datum PTS clock driver
52. [56]Harlan Stenn <harlan@pfcs.com> GNU automake/autoconfigure
50. [54]Ray Schnitzler <schnitz@unipress.com> Unixware1 port
51. [55]Michael Shields <shields@tembel.org> USNO clock driver
52. [56]Jeff Steinman <jss@pebbles.jpl.nasa.gov> Datum PTS clock driver
53. [57]Harlan Stenn <harlan@pfcs.com> GNU automake/autoconfigure
makeover, various other bits (see the ChangeLog)
53. [57]Kenneth Stone <ken@sdd.hp.com> HP-UX port
54. [58]Ajit Thyagarajan <ajit@ee.udel.edu>IP multicast/anycast support
55. [59]Tomoaki TSURUOKA <tsuruoka@nc.fukuoka-u.ac.jp>TRAK clock driver
56. [60]Brian Utterback <brian.utterback@oracle.com> General codebase,
54. [58]Kenneth Stone <ken@sdd.hp.com> HP-UX port
55. [59]Ajit Thyagarajan <ajit@ee.udel.edu>IP multicast/anycast support
56. [60]Tomoaki TSURUOKA <tsuruoka@nc.fukuoka-u.ac.jp>TRAK clock driver
57. [61]Brian Utterback <brian.utterback@oracle.com> General codebase,
Solaris issues
57. [61]Loganaden Velvindron <loganaden@gmail.com> Sandboxing
58. [62]Loganaden Velvindron <loganaden@gmail.com> Sandboxing
(libseccomp) support
58. [62]Paul A Vixie <vixie@vix.com> TrueTime GPS driver, generic
59. [63]Paul A Vixie <vixie@vix.com> TrueTime GPS driver, generic
TrueTime clock driver
59. [63]Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de> corrected and
60. [64]Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de> corrected and
validated HTML documents according to the HTML DTD
__________________________________________________________________
@ -172,51 +174,52 @@ References
13. mailto:%20reg@dwf.com
14. mailto:%20clift@ml.csiro.au
15. mailto:%20casey@csc.co.za
16. mailto:%20Sven_Dietrich@trimble.COM
17. mailto:%20dundas@salt.jpl.nasa.gov
18. mailto:%20duwe@immd4.informatik.uni-erlangen.de
19. mailto:%20dennis@mrbill.canet.ca
20. mailto:%20jhay@icomtek.csir.co.za
21. mailto:%20davehart@davehart.com
22. mailto:%20neoclock4x@linum.com
23. mailto:%20glenn@herald.usask.ca
24. mailto:%20iglesias@uci.edu
25. mailto:%20jagubox.gsfc.nasa.gov
26. mailto:%20jbj@chatham.usdesign.com
27. mailto:%20Hans.Lambermont@nl.origin-it.com
28. mailto:H.Lambermont@chello.nl
29. mailto:%20phk@FreeBSD.ORG
30. http://www4.informatik.uni-erlangen.de/%7ekardel
31. mailto:%20kardel%20%28at%29%20ntp%20%28dot%29%20org
32. mailto:kuehn@ntp.org
33. mailto:%20jones@hermes.chpc.utexas.edu
34. mailto:%20dkatz@cisco.com
35. mailto:%20leres@ee.lbl.gov
36. mailto:%20lindholm@ucs.ubc.ca
37. mailto:%20louie@ni.umd.edu
38. mailto:%20thorinn@diku.dk
39. mailto:%20mayer@ntp.org
40. mailto:%20mills@udel.edu
41. mailto:%20moeller@gwdgv1.dnet.gwdg.de
42. mailto:%20mogul@pa.dec.com
43. mailto:%20tmoore@fievel.daytonoh.ncr.com
44. mailto:%20kamal@whence.com
45. mailto:%20derek@toybox.demon.co.uk
46. mailto:%20d@hd.org
47. mailto:%20neal@ntp.org
48. mailto:%20Rainer.Pruy@informatik.uni-erlangen.de
49. mailto:%20dirce@zk3.dec.com
50. mailto:%20wsanchez@apple.com
51. mailto:%20mrapple@quack.kfu.com
52. mailto:%20jack@innovativeinternet.com
53. mailto:%20schnitz@unipress.com
54. mailto:%20shields@tembel.org
55. mailto:%20pebbles.jpl.nasa.gov
56. mailto:%20harlan@pfcs.com
57. mailto:%20ken@sdd.hp.com
58. mailto:%20ajit@ee.udel.edu
59. mailto:%20tsuruoka@nc.fukuoka-u.ac.jp
60. mailto:%20brian.utterback@oracle.com
61. mailto:%20loganaden@gmail.com
62. mailto:%20vixie@vix.com
63. mailto:%20Ulrich.Windl@rz.uni-regensburg.de
16. mailto:%20phdm@macqel.be
17. mailto:%20Sven_Dietrich@trimble.COM
18. mailto:%20dundas@salt.jpl.nasa.gov
19. mailto:%20duwe@immd4.informatik.uni-erlangen.de
20. mailto:%20dennis@mrbill.canet.ca
21. mailto:%20jhay@icomtek.csir.co.za
22. mailto:%20davehart@gmail.com
23. mailto:%20neoclock4x@linum.com
24. mailto:%20glenn@herald.usask.ca
25. mailto:%20iglesias@uci.edu
26. mailto:%20jagubox.gsfc.nasa.gov
27. mailto:%20jbj@chatham.usdesign.com
28. mailto:%20Hans.Lambermont@nl.origin-it.com
29. mailto:H.Lambermont@chello.nl
30. mailto:%20phk@FreeBSD.ORG
31. http://www4.informatik.uni-erlangen.de/%7ekardel
32. mailto:%20kardel%20%28at%29%20ntp%20%28dot%29%20org
33. mailto:kuehn@ntp.org
34. mailto:%20jones@hermes.chpc.utexas.edu
35. mailto:%20dkatz@cisco.com
36. mailto:%20leres@ee.lbl.gov
37. mailto:%20lindholm@ucs.ubc.ca
38. mailto:%20louie@ni.umd.edu
39. mailto:%20thorinn@diku.dk
40. mailto:%20mayer@ntp.org
41. mailto:%20mills@udel.edu
42. mailto:%20moeller@gwdgv1.dnet.gwdg.de
43. mailto:%20mogul@pa.dec.com
44. mailto:%20tmoore@fievel.daytonoh.ncr.com
45. mailto:%20kamal@whence.com
46. mailto:%20derek@toybox.demon.co.uk
47. mailto:%20d@hd.org
48. mailto:%20neal@ntp.org
49. mailto:%20Rainer.Pruy@informatik.uni-erlangen.de
50. mailto:%20dirce@zk3.dec.com
51. mailto:%20wsanchez@apple.com
52. mailto:%20mrapple@quack.kfu.com
53. mailto:%20jack@innovativeinternet.com
54. mailto:%20schnitz@unipress.com
55. mailto:%20shields@tembel.org
56. mailto:%20pebbles.jpl.nasa.gov
57. mailto:%20harlan@pfcs.com
58. mailto:%20ken@sdd.hp.com
59. mailto:%20ajit@ee.udel.edu
60. mailto:%20tsuruoka@nc.fukuoka-u.ac.jp
61. mailto:%20brian.utterback@oracle.com
62. mailto:%20loganaden@gmail.com
63. mailto:%20vixie@vix.com
64. mailto:%20Ulrich.Windl@rz.uni-regensburg.de

114
ChangeLog
View File

@ -1,6 +1,113 @@
---
(4.2.8p16) 2023/05/31 Released by Harlan Stenn <stenn@ntp.org>
* [Sec 3808] Assertion failure in ntpq on malformed RT-11 date <perlinger@ntp.org>
* [Sec 3807] praecis_parse() in the Palisade refclock driver has a
hypothetical input buffer overflow. Reported by ... stenn@
* [Sec 3806] libntp/mstolfp.c needs bounds checking <perlinger@ntp.org>
- solved numerically instead of using string manipulation
* [Sec 3767] An OOB KoD RATE value triggers an assertion when debug is enabled.
<stenn@ntp.org>
* [Bug 3819] Updated libopts/Makefile.am was missing NTP_HARD_* values. <stenn@>
* [Bug 3817] Bounds-check "tos floor" configuration. <hart@ntp.org>
* [Bug 3814] First poll delay of new or cleared associations miscalculated.
<hart@ntp.org>
* [Bug 3802] ntp-keygen -I default identity modulus bits too small for
OpenSSL 3. Reported by rmsh1216@163.com <hart@ntp.org>
* [Bug 3801] gpsdjson refclock gps_open() device name mishandled. <hart@ntp.org>
* [Bug 3800] libopts-42.1.17 does not compile with Microsoft C. <hart@ntp.org>
* [Bug 3799] Enable libopts noreturn compiler advice for MSC. <hart@ntp.org>
* [Bug 3797] Windows getaddrinfo w/AI_ADDRCONFIG fails for localhost when
disconnected, breaking ntpq and ntpdc. <hart@ntp.org>
* [Bug 3795] pollskewlist documentation uses | when it shouldn't.
- ntp.conf manual page and miscopt.html corrections. <hart@ntp.org>
* [Bug 3793] Wrong variable type passed to record_raw_stats(). <hart@ntp.org>
- Report and patch by Yuezhen LUAN <wei6410@sina.com>.
* [Bug 3786] Timer starvation on high-load Windows ntpd. <hart@ntp.org>
* [Bug 3784] high-load ntpd on Windows deaf after enough ICMP TTL exceeded.
<hart@ntp.org>
* [Bug 3781] log "Unable to listen for broadcasts" for IPv4 <hart@ntp.org>
* [Bug 3774] mode 6 packets corrupted in rawstats file <hart@ntp.org>
- Reported by Edward McGuire, fix identified by <wei6410@sina.com>.
* [Bug 3758] Provide a 'device' config statement for refclocks <perlinger@ntp.org>
* [Bug 3757] Improve handling of Linux-PPS in NTPD <perlinger@ntp.org>
* [Bug 3741] 4.2.8p15 can't build with glibc 2.34 <perlinger@ntp.org>
* [Bug 3725] Make copyright of clk_wharton.c compatible with Debian.
Philippe De Muyter <phdm@macqel.be>
* [Bug 3724] ntp-keygen with openSSL 1.1.1 fails on Windows <perlinger@ntp.org>
- openssl applink needed again for openSSL-1.1.1
* [Bug 3719] configure.ac checks for closefrom() and getdtablesize() missing.
Reported by Brian Utterback, broken in 2010 by <hart@ntp.org>
* [Bug 3699] Problems handling drift file and restoring previous drifts <perlinger@ntp.org>
- command line options override config statements where applicable
- make initial frequency settings idempotent and reversible
- make sure kernel PLL gets a recovered drift componsation
* [Bug 3695] Fix memory leak with ntpq on Windows Server 2019 <perlinger@ntp.org>
* [Bug 3694] NMEA refclock seems to unnecessarily require location in messages
- misleading title; essentially a request to ignore the receiver status.
Added a mode bit for this. <perlinger@ntp.org>
* [Bug 3693] Improvement of error handling key lengths <perlinger@ntp.org>
- original patch by Richard Schmidt, with mods & unit test fixes
* [Bug 3692] /dev/gpsN requirement prevents KPPS <perlinger@ntp.org>
- implement/wrap 'realpath()' to resolve symlinks in device names
* [Bug 3691] Buffer Overflow reading GPSD output
- original patch by matt<ntpbr@mattcorallo.com>
- increased max PDU size to 4k to avoid truncation
* [Bug 3690] newline in ntp clock variable (parse) <perlinger@ntp.org>
- patch by Frank Kardel
* [Bug 3689] Extension for MD5, SHA-1 and other keys <perlinger@ntp.org>
- ntp{q,dc} now use the same password processing as ntpd does in the key
file, so having a binary secret >= 11 bytes is possible for all keys.
(This is a different approach to the problem than suggested)
* [Bug 3688] GCC 10 build errors in testsuite <perlinger@ntp.org>
* [Bug 3687] ntp_crypto_rand RNG status not known <perlinger@ntp.org>
- patch by Gerry Garvey
* [Bug 3682] Fixes for warnings when compiled without OpenSSL <perlinger@ntp.org>
- original patch by Gerry Garvey
* [Bug 3677] additional peer events not decoded in associations listing <perlinger@ntp.org>
- original patch by Gerry Garvey
* [Bug 3676] compiler warnings (CMAC, interrupt_buf, typo, fallthrough)
- applied patches by Gerry Garvey
* [Bug 3675] ntpq ccmds[] stores pointer to non-persistent storage
* [Bug 3674] ntpq command 'execute only' using '~' prefix <perlinger@ntp.org>
- idea+patch by Gerry Garvey
* [Bug 3672] fix biased selection in median cut <perlinger@ntp.org>
* [Bug 3666] avoid unlimited receive buffer allocation <perlinger@ntp.org>
- follow-up: fix inverted sense in check, reset shortfall counter
* [Bug 3660] Revert 4.2.8p15 change to manycast. <hart@ntp.org>
* [Bug 3640] document "discard monitor" and fix the code. <hart@ntp.org>
- fixed bug identified by Edward McGuire <perlinger@ntp.org>
* [Bug 3626] (SNTP) UTC offset calculation needs dst flag <perlinger@ntp.org>
- applied patch by Gerry Garvey
* [Bug 3428] ntpd spinning consuming CPU on Linux router with full table.
Reported by Israel G. Lugo. <hart@ntp.org>
* [Bug 3103] libopts zsave_warn format string too few arguments <bkorb@gnu.org>
* [Bug 2990] multicastclient incorrectly causes bind to broadcast address.
Integrated patch from Brian Utterback. <hart@ntp.org>
* [Bug 2525] Turn on automake subdir-objects across the project. <hart@ntp.org>
* [Bug 2410] syslog an error message on panic exceeded. <brian.utterback@oracle.com>
* Use correct rounding in mstolfp(). perlinger/hart
* M_ADDF should use u_int32. <hart@ntp.org>
* Only define tv_fmt_libbuf() if we will use it. <stenn@ntp.org>
* Use recv_buffer instead of the longer recv_space.X_recv_buffer. hart/stenn
* Make sure the value returned by refid_str() prints cleanly. <stenn@ntp.org>
* If DEBUG is enabled, the startup banner now says that debug assertions
are in force and that ntpd will abort if any are violated. <stenn@ntp.org>
* syslog valid incoming KoDs. <stenn@ntp.org>
* Rename a poorly-named variable. <stenn@ntp.org>
* Disable "embedded NUL in string" messages in libopts, when we can. <stenn@>
* Use https in the AC_INIT URLs in configure.ac. <stenn@ntp.org>
* Implement NTP_FUNC_REALPATH. <stenn@ntp.org>
* Lose a gmake construct in ntpd/Makefile.am. <stenn@ntp.org>
* upgrade to: autogen-5.18.16
* upgrade to: libopts-42.1.17
* upgrade to: autoconf-2.71
* upgrade to: automake-1.16.15
* Upgrade to libevent-2.1.12-stable <stenn@ntp.org>
* Support OpenSSL-3.0
---
(4.2.8p15) 2020/06/23 Released by Harlan Stenn <stenn@ntp.org>
(4.2.8p15) 2020/06/23 Released by Harlan Stenn <stenn@ntp.or>
* [Sec 3661] memory leak with AES128CMAC keys <perlinger@ntp.org>
* [Bug 3670] Regression from bad merge of 3592 and 3596 <perlinger@ntp.org>
@ -14,8 +121,7 @@
* [Bug 3662] Fix build errors on Windows with VS2008 <burnicki@ntp.org>
* [Bug 3660] Manycast orphan mode startup discovery problem. <stenn@ntp.org>
- integrated patch from Charles Claggett
* [Bug 3659] Move definition of psl[] from ntp_config.h to
ntp_config.h <perlinger@ntp.org>
* [Bug 3659] Move definition of psl[] from ntp_config.h to ntp_config.c <perlinger@ntp.org>
* [Bug 3657] Wrong "Autokey group mismatch" debug message <perlinger@ntp.org>
* [Bug 3655] ntpdc memstats hash counts <perlinger@ntp.org>
- fix by Gerry garvey
@ -26,6 +132,8 @@
* [Bug 3644] Unsynchronized server [...] selected as candidate <perlinger@ntp.org>
* [Bug 3639] refclock_jjy: TS-JJY0x can skip time sync depending on the STUS reply. <abe@ntp.org>
- applied patch by Takao Abe
* [Bug 3432] refclocks that 'write()' should check the result <perlinger@ntp.org>
- plus some more work on warnings for unchecked results
---
(4.2.8p14) 2020/03/03 Released by Harlan Stenn <stenn@ntp.org>

5757
CommitLog

File diff suppressed because it is too large Load Diff

View File

@ -52,7 +52,6 @@ EXTRA_DIST = \
\
conf \
html \
lib/isc \
libjsmn \
ports \
\

View File

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -107,7 +107,6 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_debug.m4 \
$(top_srcdir)/sntp/m4/ntp_dir_sep.m4 \
$(top_srcdir)/sntp/m4/ntp_facilitynames.m4 \
$(top_srcdir)/sntp/m4/ntp_googletest.m4 \
$(top_srcdir)/sntp/m4/ntp_harden.m4 \
$(top_srcdir)/sntp/m4/ntp_ipv6.m4 \
$(top_srcdir)/sntp/m4/ntp_lib_m.m4 \
@ -127,6 +126,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
$(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/realpath.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@ -173,9 +173,9 @@ am__recursive_targets = \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
cscope distdir dist dist-all distcheck
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
$(LISP)config.h.in
cscope distdir distdir-am dist dist-all distcheck
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \
config.h.in
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
@ -192,9 +192,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/sntp/libevent/build-aux/ar-lib \
@ -250,6 +247,8 @@ am__relativize = \
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
DIST_TARGETS = dist-gzip
# Exists only to be overridden by the user if desired.
AM_DISTCHECK_DVI_TARGET = dvi
distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
@ -271,6 +270,7 @@ CALC_TICKADJ_MS = @CALC_TICKADJ_MS@
CALC_TICKADJ_NI = @CALC_TICKADJ_NI@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_NOFORMAT = @CC_NOFORMAT@
CFLAGS = @CFLAGS@
CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@
CFLAGS_NTP = @CFLAGS_NTP@
@ -280,6 +280,8 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPFLAGS_LIBEVENT = @CPPFLAGS_LIBEVENT@
CPPFLAGS_NTP = @CPPFLAGS_NTP@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DCFD = @DCFD@
DEFS = @DEFS@
@ -292,14 +294,10 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EDITLINE_LIBS = @EDITLINE_LIBS@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
GTEST_CONFIG = @GTEST_CONFIG@
GTEST_CPPFLAGS = @GTEST_CPPFLAGS@
GTEST_CXXFLAGS = @GTEST_CXXFLAGS@
GTEST_LDFLAGS = @GTEST_LDFLAGS@
GTEST_LIBS = @GTEST_LIBS@
HAVE_INLINE = @HAVE_INLINE@
HAVE_LEAPSMEARINTERVAL = @HAVE_LEAPSMEARINTERVAL@
HAVE_RLIMIT_MEMLOCK = @HAVE_RLIMIT_MEMLOCK@
@ -510,6 +508,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@ -570,7 +569,6 @@ EXTRA_DIST = \
\
conf \
html \
lib/isc \
libjsmn \
ports \
\
@ -619,8 +617,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@ -761,8 +759,10 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir: $(DISTFILES)
distdir-am: $(DISTFILES)
$(am__remove_distdir)
test -d "$(distdir)" || mkdir "$(distdir)"
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@ -845,6 +845,10 @@ dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__post_remove_distdir)
dist-zstd: distdir
tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst
$(am__post_remove_distdir)
dist-tarZ: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@ -887,6 +891,8 @@ distcheck: dist
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
*.tar.zst*) \
zstd -dc $(distdir).tar.zst | $(am__untar) ;;\
esac
chmod -R a-w $(distdir)
chmod u+w $(distdir)
@ -902,7 +908,7 @@ distcheck: dist
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=../.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) $(AM_DISTCHECK_DVI_TARGET) \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
@ -961,7 +967,8 @@ installdirs: installdirs-recursive
installdirs-am:
install: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-recursive
install-exec: install-exec-recursive
install-exec: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
@ -1064,13 +1071,13 @@ ps-am:
uninstall-am: uninstall-local
.MAKE: $(am__recursive_targets) all check install install-am \
install-strip
install-exec install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
am--refresh check check-am clean clean-cscope clean-generic \
clean-libtool cscope cscopelist-am ctags ctags-am dist \
dist-all dist-bzip2 dist-gzip dist-hook dist-lzip dist-shar \
dist-tarZ dist-xz dist-zip distcheck distclean \
dist-tarZ dist-xz dist-zip dist-zstd distcheck distclean \
distclean-generic distclean-hdr distclean-libtool \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \

123
NEWS
View File

@ -1,3 +1,126 @@
---
NTP 4.2.8p16 (Harlan Stenn <stenn@ntp.org>, 2023 May 30)
Focus: Security, Bug fixes
Severity: LOW
This release:
- fixes 4 vulnerabilities (3 LOW and 1 None severity),
- fixes 46 bugs
- includes 15 general improvements
- adds support for OpenSSL-3.0
Details below:
* [Sec 3808] Assertion failure in ntpq on malformed RT-11 date <perlinger@ntp.org>
* [Sec 3807] praecis_parse() in the Palisade refclock driver has a
hypothetical input buffer overflow. Reported by ... stenn@
* [Sec 3806] libntp/mstolfp.c needs bounds checking <perlinger@ntp.org>
- solved numerically instead of using string manipulation
* [Sec 3767] An OOB KoD RATE value triggers an assertion when debug is enabled.
<stenn@ntp.org>
* [Bug 3819] Updated libopts/Makefile.am was missing NTP_HARD_* values. <stenn@>
* [Bug 3817] Bounds-check "tos floor" configuration. <hart@ntp.org>
* [Bug 3814] First poll delay of new or cleared associations miscalculated.
<hart@ntp.org>
* [Bug 3802] ntp-keygen -I default identity modulus bits too small for
OpenSSL 3. Reported by rmsh1216@163.com <hart@ntp.org>
* [Bug 3801] gpsdjson refclock gps_open() device name mishandled. <hart@ntp.org>
* [Bug 3800] libopts-42.1.17 does not compile with Microsoft C. <hart@ntp.org>
* [Bug 3799] Enable libopts noreturn compiler advice for MSC. <hart@ntp.org>
* [Bug 3797] Windows getaddrinfo w/AI_ADDRCONFIG fails for localhost when
disconnected, breaking ntpq and ntpdc. <hart@ntp.org>
* [Bug 3795] pollskewlist documentation uses | when it shouldn't.
- ntp.conf manual page and miscopt.html corrections. <hart@ntp.org>
* [Bug 3793] Wrong variable type passed to record_raw_stats(). <hart@ntp.org>
- Report and patch by Yuezhen LUAN <wei6410@sina.com>.
* [Bug 3786] Timer starvation on high-load Windows ntpd. <hart@ntp.org>
* [Bug 3784] high-load ntpd on Windows deaf after enough ICMP TTL exceeded.
<hart@ntp.org>
* [Bug 3781] log "Unable to listen for broadcasts" for IPv4 <hart@ntp.org>
* [Bug 3774] mode 6 packets corrupted in rawstats file <hart@ntp.org>
- Reported by Edward McGuire, fix identified by <wei6410@sina.com>.
* [Bug 3758] Provide a 'device' config statement for refclocks <perlinger@ntp.org>
* [Bug 3757] Improve handling of Linux-PPS in NTPD <perlinger@ntp.org>
* [Bug 3741] 4.2.8p15 can't build with glibc 2.34 <perlinger@ntp.org>
* [Bug 3725] Make copyright of clk_wharton.c compatible with Debian.
Philippe De Muyter <phdm@macqel.be>
* [Bug 3724] ntp-keygen with openSSL 1.1.1 fails on Windows <perlinger@ntp.org>
- openssl applink needed again for openSSL-1.1.1
* [Bug 3719] configure.ac checks for closefrom() and getdtablesize() missing.
Reported by Brian Utterback, broken in 2010 by <hart@ntp.org>
* [Bug 3699] Problems handling drift file and restoring previous drifts <perlinger@ntp.org>
- command line options override config statements where applicable
- make initial frequency settings idempotent and reversible
- make sure kernel PLL gets a recovered drift componsation
* [Bug 3695] Fix memory leak with ntpq on Windows Server 2019 <perlinger@ntp.org>
* [Bug 3694] NMEA refclock seems to unnecessarily require location in messages
- misleading title; essentially a request to ignore the receiver status.
Added a mode bit for this. <perlinger@ntp.org>
* [Bug 3693] Improvement of error handling key lengths <perlinger@ntp.org>
- original patch by Richard Schmidt, with mods & unit test fixes
* [Bug 3692] /dev/gpsN requirement prevents KPPS <perlinger@ntp.org>
- implement/wrap 'realpath()' to resolve symlinks in device names
* [Bug 3691] Buffer Overflow reading GPSD output
- original patch by matt<ntpbr@mattcorallo.com>
- increased max PDU size to 4k to avoid truncation
* [Bug 3690] newline in ntp clock variable (parse) <perlinger@ntp.org>
- patch by Frank Kardel
* [Bug 3689] Extension for MD5, SHA-1 and other keys <perlinger@ntp.org>
- ntp{q,dc} now use the same password processing as ntpd does in the key
file, so having a binary secret >= 11 bytes is possible for all keys.
(This is a different approach to the problem than suggested)
* [Bug 3688] GCC 10 build errors in testsuite <perlinger@ntp.org>
* [Bug 3687] ntp_crypto_rand RNG status not known <perlinger@ntp.org>
- patch by Gerry Garvey
* [Bug 3682] Fixes for warnings when compiled without OpenSSL <perlinger@ntp.org>
- original patch by Gerry Garvey
* [Bug 3677] additional peer events not decoded in associations listing <perlinger@ntp.org>
- original patch by Gerry Garvey
* [Bug 3676] compiler warnings (CMAC, interrupt_buf, typo, fallthrough)
- applied patches by Gerry Garvey
* [Bug 3675] ntpq ccmds[] stores pointer to non-persistent storage
* [Bug 3674] ntpq command 'execute only' using '~' prefix <perlinger@ntp.org>
- idea+patch by Gerry Garvey
* [Bug 3672] fix biased selection in median cut <perlinger@ntp.org>
* [Bug 3666] avoid unlimited receive buffer allocation <perlinger@ntp.org>
- follow-up: fix inverted sense in check, reset shortfall counter
* [Bug 3660] Revert 4.2.8p15 change to manycast. <hart@ntp.org>
* [Bug 3640] document "discard monitor" and fix the code. <hart@ntp.org>
- fixed bug identified by Edward McGuire <perlinger@ntp.org>
* [Bug 3626] (SNTP) UTC offset calculation needs dst flag <perlinger@ntp.org>
- applied patch by Gerry Garvey
* [Bug 3432] refclocks that 'write()' should check the result <perlinger@ntp.org>
- backport from -dev, plus some more work on warnings for unchecked results
* [Bug 3428] ntpd spinning consuming CPU on Linux router with full table.
Reported by Israel G. Lugo. <hart@ntp.org>
* [Bug 3103] libopts zsave_warn format string too few arguments <bkorb@gnu.org>
* [Bug 2990] multicastclient incorrectly causes bind to broadcast address.
Integrated patch from Brian Utterback. <hart@ntp.org>
* [Bug 2525] Turn on automake subdir-objects across the project. <hart@ntp.org>
* [Bug 2410] syslog an error message on panic exceeded. <brian.utterback@oracle.com>
* Use correct rounding in mstolfp(). perlinger/hart
* M_ADDF should use u_int32. <hart@ntp.org>
* Only define tv_fmt_libbuf() if we will use it. <stenn@ntp.org>
* Use recv_buffer instead of the longer recv_space.X_recv_buffer. hart/stenn
* Make sure the value returned by refid_str() prints cleanly. <stenn@ntp.org>
* If DEBUG is enabled, the startup banner now says that debug assertions
are in force and that ntpd will abort if any are violated. <stenn@ntp.org>
* syslog valid incoming KoDs. <stenn@ntp.org>
* Rename a poorly-named variable. <stenn@ntp.org>
* Disable "embedded NUL in string" messages in libopts, when we can. <stenn@>
* Use https in the AC_INIT URLs in configure.ac. <stenn@ntp.org>
* Implement NTP_FUNC_REALPATH. <stenn@ntp.org>
* Lose a gmake construct in ntpd/Makefile.am. <stenn@ntp.org>
* upgrade to: autogen-5.18.16
* upgrade to: libopts-42.1.17
* upgrade to: autoconf-2.71
* upgrade to: automake-1.16.15
* Upgrade to libevent-2.1.12-stable <stenn@ntp.org>
* Support OpenSSL-3.0
---
NTP 4.2.8p15 (Harlan Stenn <stenn@ntp.org>, 2020 Jun 23)

340
aclocal.m4 vendored
View File

@ -1,6 +1,6 @@
# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
# generated automatically by aclocal 1.16.5 -*- Autoconf -*-
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -14,127 +14,13 @@
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
[m4_warning([this file was generated for autoconf 2.69.
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.71],,
[m4_warning([this file was generated for autoconf 2.71.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
# longlong.m4 serial 17
dnl Copyright (C) 1999-2007, 2009-2016 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Paul Eggert.
# Define HAVE_LONG_LONG_INT if 'long long int' works.
# This fixes a bug in Autoconf 2.61, and can be faster
# than what's in Autoconf 2.62 through 2.68.
# Note: If the type 'long long int' exists but is only 32 bits large
# (as on some very old compilers), HAVE_LONG_LONG_INT will not be
# defined. In this case you can treat 'long long int' like 'long int'.
AC_DEFUN([AC_TYPE_LONG_LONG_INT],
[
AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
[ac_cv_type_long_long_int=yes
if test "x${ac_cv_prog_cc_c99-no}" = xno; then
ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int
if test $ac_cv_type_long_long_int = yes; then
dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
dnl If cross compiling, assume the bug is not important, since
dnl nobody cross compiles for this platform as far as we know.
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[@%:@include <limits.h>
@%:@ifndef LLONG_MAX
@%:@ define HALF \
(1LL << (sizeof (long long int) * CHAR_BIT - 2))
@%:@ define LLONG_MAX (HALF - 1 + HALF)
@%:@endif]],
[[long long int n = 1;
int i;
for (i = 0; ; i++)
{
long long int m = n << i;
if (m >> i != n)
return 1;
if (LLONG_MAX / 2 < m)
break;
}
return 0;]])],
[],
[ac_cv_type_long_long_int=no],
[:])
fi
fi])
if test $ac_cv_type_long_long_int = yes; then
AC_DEFINE([HAVE_LONG_LONG_INT], [1],
[Define to 1 if the system has the type 'long long int'.])
fi
])
# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works.
# This fixes a bug in Autoconf 2.61, and can be faster
# than what's in Autoconf 2.62 through 2.68.
# Note: If the type 'unsigned long long int' exists but is only 32 bits
# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT
# will not be defined. In this case you can treat 'unsigned long long int'
# like 'unsigned long int'.
AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
[
AC_CACHE_CHECK([for unsigned long long int],
[ac_cv_type_unsigned_long_long_int],
[ac_cv_type_unsigned_long_long_int=yes
if test "x${ac_cv_prog_cc_c99-no}" = xno; then
AC_LINK_IFELSE(
[_AC_TYPE_LONG_LONG_SNIPPET],
[],
[ac_cv_type_unsigned_long_long_int=no])
fi])
if test $ac_cv_type_unsigned_long_long_int = yes; then
AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
[Define to 1 if the system has the type 'unsigned long long int'.])
fi
])
# Expands to a C program that can be used to test for simultaneous support
# of 'long long' and 'unsigned long long'. We don't want to say that
# 'long long' is available if 'unsigned long long' is not, or vice versa,
# because too many programs rely on the symmetry between signed and unsigned
# integer types (excluding 'bool').
AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
[
AC_LANG_PROGRAM(
[[/* For now, do not test the preprocessor; as of 2007 there are too many
implementations with broken preprocessors. Perhaps this can
be revisited in 2012. In the meantime, code should not expect
#if to work with literals wider than 32 bits. */
/* Test literals. */
long long int ll = 9223372036854775807ll;
long long int nll = -9223372036854775807LL;
unsigned long long int ull = 18446744073709551615ULL;
/* Test constant expressions. */
typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
? 1 : -1)];
typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
? 1 : -1)];
int i = 63;]],
[[/* Test availability of runtime routines for shift and division. */
long long int llmax = 9223372036854775807ll;
unsigned long long int ullmax = 18446744073709551615ull;
return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
| (llmax / ll) | (llmax % ll)
| (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
| (ullmax / ull) | (ullmax % ull));]])
])
# Copyright (C) 2002-2017 Free Software Foundation, Inc.
# Copyright (C) 2002-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -146,10 +32,10 @@ AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.15'
[am__api_version='1.16'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.15.1], [],
m4_if([$1], [1.16.5], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@ -165,12 +51,12 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.15.1])dnl
[AM_AUTOMAKE_VERSION([1.16.5])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# Copyright (C) 2011-2017 Free Software Foundation, Inc.
# Copyright (C) 2011-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -232,7 +118,7 @@ AC_SUBST([AR])dnl
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -284,7 +170,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997-2017 Free Software Foundation, Inc.
# Copyright (C) 1997-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -315,7 +201,7 @@ AC_CONFIG_COMMANDS_PRE(
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -506,13 +392,12 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
@ -520,49 +405,43 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
# Older Autoconf quotes --file arguments for eval, but not when files
# are listed without --file. Let's play safe and only enable the eval
# if we detect the quoting.
case $CONFIG_FILES in
*\'*) eval set x "$CONFIG_FILES" ;;
*) set x $CONFIG_FILES ;;
esac
# TODO: see whether this extra hack can be removed once we start
# requiring Autoconf 2.70 or later.
AS_CASE([$CONFIG_FILES],
[*\'*], [eval set x "$CONFIG_FILES"],
[*], [set x $CONFIG_FILES])
shift
for mf
# Used to flag and report bootstrapping failures.
am_rc=0
for am_mf
do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named 'Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# Grep'ing the whole file is not good either: AIX grep has a line
am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile which includes
# dependency-tracking related rules and includes.
# Grep'ing the whole file directly is not great: AIX grep has a line
# limit of 2048, but all sed's we know have understand at least 4000.
if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
# Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running 'make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "$am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the
# expansion.
for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \
|| continue
am_dirpart=`AS_DIRNAME(["$am_mf"])`
am_filepart=`AS_BASENAME(["$am_mf"])`
AM_RUN_LOG([cd "$am_dirpart" \
&& sed -e '/# am--include-marker/d' "$am_filepart" \
| $MAKE -f - am--depfiles]) || am_rc=$?
done
if test $am_rc -ne 0; then
AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments
for automatic dependency tracking. If GNU make was not used, consider
re-running the configure script with MAKE="gmake" (or whatever is
necessary). You can also try re-running configure with the
'--disable-dependency-tracking' option to at least be able to build
the package (albeit without support for automatic dependency tracking).])
fi
AS_UNSET([am_dirpart])
AS_UNSET([am_filepart])
AS_UNSET([am_mf])
AS_UNSET([am_rc])
rm -f conftest-deps.mk
}
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
@ -571,18 +450,17 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
# -----------------------------
# This macro should only be invoked once -- use via AC_REQUIRE.
#
# This code is only required when automatic dependency tracking
# is enabled. FIXME. This creates each '.P' file that we will
# need in order to bootstrap the dependency handling code.
# This code is only required when automatic dependency tracking is enabled.
# This creates each '.Po' and '.Plo' makefile fragment that we'll need in
# order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
])
[AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])])
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -610,6 +488,10 @@ m4_defn([AC_PROG_CC])
# release and drop the old call support.
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_PREREQ([2.65])dnl
m4_ifdef([_$0_ALREADY_INIT],
[m4_fatal([$0 expanded multiple times
]m4_defn([_$0_ALREADY_INIT]))],
[m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl
dnl Autoconf wants to disallow AM_ names. We explicitly allow
dnl the ones we care about.
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
@ -646,7 +528,7 @@ m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
[_AM_SET_OPTIONS([$1])dnl
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
m4_if(
m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]),
[ok:ok],,
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
@ -669,8 +551,8 @@ AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
AC_REQUIRE([AC_PROG_MKDIR_P])dnl
# For better backward compatibility. To be removed once Automake 1.9.x
# dies out for good. For more background, see:
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
# <https://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
# <https://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
# We need awk for the "check" target (and possibly the TAP driver). The
# system "awk" is bad on some platforms.
@ -698,6 +580,20 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
[m4_define([AC_PROG_OBJCXX],
m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
])
# Variables for tags utilities; see am/tags.am
if test -z "$CTAGS"; then
CTAGS=ctags
fi
AC_SUBST([CTAGS])
if test -z "$ETAGS"; then
ETAGS=etags
fi
AC_SUBST([ETAGS])
if test -z "$CSCOPE"; then
CSCOPE=cscope
fi
AC_SUBST([CSCOPE])
AC_REQUIRE([AM_SILENT_RULES])dnl
dnl The testsuite driver may need to know about EXEEXT, so add the
dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This
@ -737,7 +633,7 @@ END
Aborting the configuration process, to ensure you take notice of the issue.
You can download and install GNU coreutils to get an 'rm' implementation
that behaves properly: <http://www.gnu.org/software/coreutils/>.
that behaves properly: <https://www.gnu.org/software/coreutils/>.
If you want to complete the configuration process using your problematic
'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
@ -779,7 +675,7 @@ for _am_header in $config_headers :; do
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -800,7 +696,7 @@ if test x"${install_sh+set}" != xset; then
fi
AC_SUBST([install_sh])])
# Copyright (C) 2003-2017 Free Software Foundation, Inc.
# Copyright (C) 2003-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -821,7 +717,7 @@ AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -829,49 +725,42 @@ AC_SUBST([am__leading_dot])])
# AM_MAKE_INCLUDE()
# -----------------
# Check to see how make treats includes.
# Check whether make has an 'include' directive that can support all
# the idioms we need for our automatic dependency tracking code.
AC_DEFUN([AM_MAKE_INCLUDE],
[am_make=${MAKE-make}
cat > confinc << 'END'
[AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive])
cat > confinc.mk << 'END'
am__doit:
@echo this is the am__doit target
@echo this is the am__doit target >confinc.out
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
AC_MSG_CHECKING([for style of include used by $am_make])
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# Ignore all kinds of additional output from 'make'.
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=include
am__quote=
_am_result=GNU
;;
esac
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=.include
am__quote="\""
_am_result=BSD
;;
esac
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# BSD make does it like this.
echo '.include "confinc.mk" # ignored' > confmf.BSD
# Other make implementations (GNU, Solaris 10, AIX) do it like this.
echo 'include confinc.mk # ignored' > confmf.GNU
_am_result=no
for s in GNU BSD; do
AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out])
AS_CASE([$?:`cat confinc.out 2>/dev/null`],
['0:this is the am__doit target'],
[AS_CASE([$s],
[BSD], [am__include='.include' am__quote='"'],
[am__include='include' am__quote=''])])
if test "$am__include" != "#"; then
_am_result="yes ($s style)"
break
fi
done
rm -f confinc.* confmf.*
AC_MSG_RESULT([${_am_result}])
AC_SUBST([am__include])])
AC_SUBST([am__quote])])
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997-2017 Free Software Foundation, Inc.
# Copyright (C) 1997-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -892,12 +781,7 @@ AC_DEFUN([AM_MISSING_HAS_RUN],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([missing])dnl
if test x"${MISSING+set}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
*)
MISSING="\${SHELL} $am_aux_dir/missing" ;;
esac
MISSING="\${SHELL} '$am_aux_dir/missing'"
fi
# Use eval to expand $SHELL
if eval "$MISSING --is-lightweight"; then
@ -910,7 +794,7 @@ fi
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -939,7 +823,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -986,7 +870,7 @@ AC_LANG_POP([C])])
# For backward compatibility.
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -1005,7 +889,7 @@ AC_DEFUN([AM_RUN_LOG],
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -1086,7 +970,7 @@ AC_CONFIG_COMMANDS_PRE(
rm -f conftest.file
])
# Copyright (C) 2009-2017 Free Software Foundation, Inc.
# Copyright (C) 2009-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -1146,7 +1030,7 @@ AC_SUBST([AM_BACKSLASH])dnl
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
])
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -1174,7 +1058,7 @@ fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Copyright (C) 2006-2017 Free Software Foundation, Inc.
# Copyright (C) 2006-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -1193,7 +1077,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004-2017 Free Software Foundation, Inc.
# Copyright (C) 2004-2021 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -1342,7 +1226,6 @@ m4_include([sntp/m4/ntp_crypto_rand.m4])
m4_include([sntp/m4/ntp_debug.m4])
m4_include([sntp/m4/ntp_dir_sep.m4])
m4_include([sntp/m4/ntp_facilitynames.m4])
m4_include([sntp/m4/ntp_googletest.m4])
m4_include([sntp/m4/ntp_harden.m4])
m4_include([sntp/m4/ntp_ipv6.m4])
m4_include([sntp/m4/ntp_lib_m.m4])
@ -1362,4 +1245,5 @@ m4_include([sntp/m4/ntp_vpathhack.m4])
m4_include([sntp/m4/openldap-thread-check.m4])
m4_include([sntp/m4/openldap.m4])
m4_include([sntp/m4/os_cflags.m4])
m4_include([sntp/m4/realpath.m4])
m4_include([sntp/m4/snprintf.m4])

View File

@ -6,6 +6,7 @@ sbin_PROGRAMS = $(ADJTIMED_DS)
BUILT_SOURCES =
CLEANFILES =
DISTCLEANFILES =
EXTRA_PROGRAMS = adjtimed
AM_CFLAGS = $(CFLAGS_NTP)
@ -19,6 +20,6 @@ LDADD = ../libntp/libntp.a $(LDADD_LIBNTP) $(LIBM) $(PTHREAD_LIBS)
AM_LDFLAGS = $(NTP_HARD_LDFLAGS)
include $(top_srcdir)/bincheck.mf
include $(top_srcdir)/sntp/check-libntp.mf
include $(top_srcdir)/check-libntp.mf
include $(top_srcdir)/depsver.mf
include $(top_srcdir)/includes.mf

View File

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -116,7 +116,6 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_debug.m4 \
$(top_srcdir)/sntp/m4/ntp_dir_sep.m4 \
$(top_srcdir)/sntp/m4/ntp_facilitynames.m4 \
$(top_srcdir)/sntp/m4/ntp_googletest.m4 \
$(top_srcdir)/sntp/m4/ntp_harden.m4 \
$(top_srcdir)/sntp/m4/ntp_ipv6.m4 \
$(top_srcdir)/sntp/m4/ntp_lib_m.m4 \
@ -136,6 +135,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
$(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/realpath.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@ -172,7 +172,8 @@ am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/sntp/libevent/build-aux/depcomp
am__depfiles_maybe = depfiles
am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/adjtimed.Po
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@ -216,11 +217,9 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/bincheck.mf \
$(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf \
$(top_srcdir)/sntp/check-libntp.mf \
$(top_srcdir)/check-libntp.mf $(top_srcdir)/depsver.mf \
$(top_srcdir)/includes.mf \
$(top_srcdir)/sntp/libevent/build-aux/depcomp README
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
@ -240,6 +239,7 @@ CALC_TICKADJ_MS = @CALC_TICKADJ_MS@
CALC_TICKADJ_NI = @CALC_TICKADJ_NI@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_NOFORMAT = @CC_NOFORMAT@
CFLAGS = @CFLAGS@
CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@
CFLAGS_NTP = @CFLAGS_NTP@
@ -249,6 +249,8 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPFLAGS_LIBEVENT = @CPPFLAGS_LIBEVENT@
CPPFLAGS_NTP = @CPPFLAGS_NTP@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DCFD = @DCFD@
DEFS = @DEFS@
@ -261,14 +263,10 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EDITLINE_LIBS = @EDITLINE_LIBS@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
GTEST_CONFIG = @GTEST_CONFIG@
GTEST_CPPFLAGS = @GTEST_CPPFLAGS@
GTEST_CXXFLAGS = @GTEST_CXXFLAGS@
GTEST_LDFLAGS = @GTEST_LDFLAGS@
GTEST_LIBS = @GTEST_LIBS@
HAVE_INLINE = @HAVE_INLINE@
HAVE_LEAPSMEARINTERVAL = @HAVE_LEAPSMEARINTERVAL@
HAVE_RLIMIT_MEMLOCK = @HAVE_RLIMIT_MEMLOCK@
@ -479,6 +477,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@ -490,19 +489,21 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
BUILT_SOURCES = check-libntp .deps-ver
CLEANFILES = check-libntp .deps-ver
DISTCLEANFILES = $(DEPDIR)/deps-ver
AM_CFLAGS = $(CFLAGS_NTP) $(NTP_HARD_CFLAGS)
AM_CPPFLAGS = $(NTP_INCS) $(CPPFLAGS_NTP) $(NTP_HARD_CPPFLAGS)
LDADD = ../libntp/libntp.a $(LDADD_LIBNTP) $(LIBM) $(PTHREAD_LIBS)
AM_LDFLAGS = $(NTP_HARD_LDFLAGS)
NTP_INCS = -I$(top_srcdir)/include -I$(top_srcdir)/lib/isc/include \
-I$(top_srcdir)/lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/include \
-I$(top_srcdir)/lib/isc/unix/include
NTP_INCS = -I$(top_srcdir)/include \
-I$(top_srcdir)/libntp/lib/isc/include \
-I$(top_srcdir)/libntp/lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/include \
-I$(top_srcdir)/libntp/lib/isc/unix/include
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/bincheck.mf $(top_srcdir)/sntp/check-libntp.mf $(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf $(am__configure_deps)
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/bincheck.mf $(top_srcdir)/check-libntp.mf $(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
@ -519,10 +520,10 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_srcdir)/bincheck.mf $(top_srcdir)/sntp/check-libntp.mf $(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf $(am__empty):
$(top_srcdir)/bincheck.mf $(top_srcdir)/check-libntp.mf $(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf $(am__empty):
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
@ -690,25 +691,34 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adjtimed.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adjtimed.Po@am__quote@ # am--include-marker
$(am__depfiles_remade):
@$(MKDIR_P) $(@D)
@echo '# dummy' >$@-t && $(am__mv) $@-t $@
am--depfiles: $(am__depfiles_remade)
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
@ -770,8 +780,10 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir: $(DISTFILES)
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
@ -811,7 +823,8 @@ installdirs:
done
install: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-am
install-exec: install-exec-am
install-exec: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-exec-am
install-data: install-data-am
uninstall: uninstall-am
@ -837,6 +850,7 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@ -848,7 +862,7 @@ clean-am: clean-binPROGRAMS clean-generic clean-libexecPROGRAMS \
clean-libtool clean-sbinPROGRAMS mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f ./$(DEPDIR)/adjtimed.Po
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
@ -896,7 +910,7 @@ install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f ./$(DEPDIR)/adjtimed.Po
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
@ -916,9 +930,10 @@ ps-am:
uninstall-am: uninstall-binPROGRAMS uninstall-libexecPROGRAMS \
uninstall-sbinPROGRAMS
.MAKE: all check install install-am install-exec-am install-strip
.MAKE: all check install install-am install-exec install-exec-am \
install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
clean-binPROGRAMS clean-generic clean-libexecPROGRAMS \
clean-libtool clean-sbinPROGRAMS cscopelist-am ctags ctags-am \
distclean distclean-compile distclean-generic \
@ -952,17 +967,18 @@ install-exec-hook:
#
check-libntp: ../libntp/libntp.a
check-libntp: $(top_builddir)/libntp/libntp.a
@: avoid default SCCS get by some make implementations
../libntp/libntp.a:
cd ../libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
$(top_builddir)/libntp/libntp.a:
cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
$(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
@[ -f $@ ] || \
cp $(top_srcdir)/deps-ver $@
@[ -w $@ ] || \
chmod ug+w $@
chmod u+w $@
@cmp $(top_srcdir)/deps-ver $@ > /dev/null || ( \
$(MAKE) $(AM_MAKEFLAGS) clean && \
$(MAKE) $(AM_MAKEFLAGS) clean && \
echo -n "Prior $(subdir)/$(DEPDIR) version " && \
cat $@ && \
rm -rf $(DEPDIR) && \
@ -980,7 +996,7 @@ $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
echo -n "Cleaned $(subdir)/$(DEPDIR) version " && \
cat $(top_srcdir)/deps-ver \
)
cp $(top_srcdir)/deps-ver $@
$(AM_V_at)cp $(top_srcdir)/deps-ver $@
.deps-ver: $(top_srcdir)/deps-ver
@[ ! -d $(DEPDIR) ] || $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/deps-ver
@ -1010,7 +1026,7 @@ $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
# If you modify depsver.mf, please make the changes to the master
# copy, the one in sntp is copied by the bootstrap script from it.
#
# This comment block follows rather than leads the related code so that
# This comment block follows rather than leads the related rules so that
# it stays with it in the generated Makefile.in and Makefile.
#

14
check-libntp.mf Normal file
View File

@ -0,0 +1,14 @@
## check-libntp.mf - automake fragment
##
## sntp/check-libntp.mf
## The above file has a version of this for the sntp tree.
BUILT_SOURCES += check-libntp
CLEANFILES += check-libntp
check-libntp: $(top_builddir)/libntp/libntp.a
@: avoid default SCCS get by some make implementations
$(top_builddir)/libntp/libntp.a:
cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a

19
check-libntpd.mf Normal file
View File

@ -0,0 +1,19 @@
##
## check-libntpd.mf - automake fragment
##
BUILT_SOURCES += check-libntpd
# CLEANFILES addition below won't be needed after a while.
# Leave it in for now for folks tracking the source repo
# who have the file from a former version of the rule.
# DLH Jan 2023
CLEANFILES += check-libntpd
check-libntpd: $(top_builddir)/ntpd/libntpd.a
@: avoid default SCCS get by some make implementations
$(top_builddir)/ntpd/libntpd.a:
cd $(top_builddir)/ntpd && $(MAKE) $(AM_MAKEFLAGS) libntpd.a

13
check-libunity.mf Normal file
View File

@ -0,0 +1,13 @@
## check-libunity.mf - automake fragment
##
## sntp/check-libunity.mf
## The above file has a version of this for the sntp tree.
BUILT_SOURCES += check-libunity
check-libunity: $(top_builddir)/sntp/unity/libunity.a
@: avoid default SCCS get by some make implementations
$(top_builddir)/sntp/unity/libunity.a:
cd $(top_builddir)/sntp/unity && $(MAKE) $(AM_MAKEFLAGS) libunity.a

8
check-scm-rev.mf Normal file
View File

@ -0,0 +1,8 @@
$(top_srcdir)/sntp/scm-rev: FRC.scm-rev
$(AM_V_GEN)cd $(top_builddir)/sntp && $(MAKE) $(AM_MAKEFLAGS) check-scm-rev
FRC.scm-rev:
@: FRC.scm-rev "force" depends on nothing and is not a file, so is \
always out-of-date causing targets which depend on it to also \
be outdated so their rules to fire each time they are built.

View File

@ -14,7 +14,8 @@ propdelay_LDADD = $(LDADD)
BUILT_SOURCES =
CLEANFILES =
DISTCLEANFILES =
include $(top_srcdir)/sntp/check-libntp.mf
include $(top_srcdir)/check-libntp.mf
include $(top_srcdir)/depsver.mf
include $(top_srcdir)/includes.mf

View File

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -109,7 +109,6 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_debug.m4 \
$(top_srcdir)/sntp/m4/ntp_dir_sep.m4 \
$(top_srcdir)/sntp/m4/ntp_facilitynames.m4 \
$(top_srcdir)/sntp/m4/ntp_googletest.m4 \
$(top_srcdir)/sntp/m4/ntp_harden.m4 \
$(top_srcdir)/sntp/m4/ntp_ipv6.m4 \
$(top_srcdir)/sntp/m4/ntp_lib_m.m4 \
@ -129,6 +128,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
$(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/realpath.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@ -168,7 +168,8 @@ am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/sntp/libevent/build-aux/depcomp
am__depfiles_maybe = depfiles
am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/chutest.Po ./$(DEPDIR)/propdelay.Po
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@ -212,10 +213,8 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depsver.mf \
$(top_srcdir)/includes.mf $(top_srcdir)/sntp/check-libntp.mf \
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/check-libntp.mf \
$(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf \
$(top_srcdir)/sntp/libevent/build-aux/depcomp README
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
@ -235,6 +234,7 @@ CALC_TICKADJ_MS = @CALC_TICKADJ_MS@
CALC_TICKADJ_NI = @CALC_TICKADJ_NI@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_NOFORMAT = @CC_NOFORMAT@
CFLAGS = @CFLAGS@
CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@
CFLAGS_NTP = @CFLAGS_NTP@
@ -244,6 +244,8 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPFLAGS_LIBEVENT = @CPPFLAGS_LIBEVENT@
CPPFLAGS_NTP = @CPPFLAGS_NTP@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DCFD = @DCFD@
DEFS = @DEFS@
@ -256,14 +258,10 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EDITLINE_LIBS = @EDITLINE_LIBS@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
GTEST_CONFIG = @GTEST_CONFIG@
GTEST_CPPFLAGS = @GTEST_CPPFLAGS@
GTEST_CXXFLAGS = @GTEST_CXXFLAGS@
GTEST_LDFLAGS = @GTEST_LDFLAGS@
GTEST_LIBS = @GTEST_LIBS@
HAVE_INLINE = @HAVE_INLINE@
HAVE_LEAPSMEARINTERVAL = @HAVE_LEAPSMEARINTERVAL@
HAVE_RLIMIT_MEMLOCK = @HAVE_RLIMIT_MEMLOCK@
@ -474,6 +472,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@ -491,15 +490,17 @@ AM_LDFLAGS = $(NTP_HARD_LDFLAGS)
propdelay_LDADD = $(LDADD)
BUILT_SOURCES = check-libntp .deps-ver
CLEANFILES = check-libntp .deps-ver
NTP_INCS = -I$(top_srcdir)/include -I$(top_srcdir)/lib/isc/include \
-I$(top_srcdir)/lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/include \
-I$(top_srcdir)/lib/isc/unix/include
DISTCLEANFILES = $(DEPDIR)/deps-ver
NTP_INCS = -I$(top_srcdir)/include \
-I$(top_srcdir)/libntp/lib/isc/include \
-I$(top_srcdir)/libntp/lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/include \
-I$(top_srcdir)/libntp/lib/isc/unix/include
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/sntp/check-libntp.mf $(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf $(am__configure_deps)
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/check-libntp.mf $(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
@ -516,10 +517,10 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_srcdir)/sntp/check-libntp.mf $(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf $(am__empty):
$(top_srcdir)/check-libntp.mf $(top_srcdir)/depsver.mf $(top_srcdir)/includes.mf $(am__empty):
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
@ -553,26 +554,35 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chutest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/propdelay.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chutest.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/propdelay.Po@am__quote@ # am--include-marker
$(am__depfiles_remade):
@$(MKDIR_P) $(@D)
@echo '# dummy' >$@-t && $(am__mv) $@-t $@
am--depfiles: $(am__depfiles_remade)
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
@ -634,8 +644,10 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir: $(DISTFILES)
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
@ -672,7 +684,8 @@ all-am: Makefile $(PROGRAMS)
installdirs:
install: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-am
install-exec: install-exec-am
install-exec: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-exec-am
install-data: install-data-am
uninstall: uninstall-am
@ -698,6 +711,7 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@ -709,7 +723,8 @@ clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f ./$(DEPDIR)/chutest.Po
-rm -f ./$(DEPDIR)/propdelay.Po
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
@ -755,7 +770,8 @@ install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f ./$(DEPDIR)/chutest.Po
-rm -f ./$(DEPDIR)/propdelay.Po
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
@ -774,11 +790,11 @@ ps-am:
uninstall-am:
.MAKE: all check install install-am install-strip
.MAKE: all check install install-am install-exec install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \
ctags-am distclean distclean-compile distclean-generic \
.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
clean-generic clean-libtool clean-noinstPROGRAMS cscopelist-am \
ctags ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
@ -793,17 +809,18 @@ uninstall-am:
.PRECIOUS: Makefile
check-libntp: ../libntp/libntp.a
check-libntp: $(top_builddir)/libntp/libntp.a
@: avoid default SCCS get by some make implementations
../libntp/libntp.a:
cd ../libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
$(top_builddir)/libntp/libntp.a:
cd $(top_builddir)/libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
$(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
@[ -f $@ ] || \
cp $(top_srcdir)/deps-ver $@
@[ -w $@ ] || \
chmod ug+w $@
chmod u+w $@
@cmp $(top_srcdir)/deps-ver $@ > /dev/null || ( \
$(MAKE) $(AM_MAKEFLAGS) clean && \
$(MAKE) $(AM_MAKEFLAGS) clean && \
echo -n "Prior $(subdir)/$(DEPDIR) version " && \
cat $@ && \
rm -rf $(DEPDIR) && \
@ -821,7 +838,7 @@ $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
echo -n "Cleaned $(subdir)/$(DEPDIR) version " && \
cat $(top_srcdir)/deps-ver \
)
cp $(top_srcdir)/deps-ver $@
$(AM_V_at)cp $(top_srcdir)/deps-ver $@
.deps-ver: $(top_srcdir)/deps-ver
@[ ! -d $(DEPDIR) ] || $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/deps-ver
@ -851,7 +868,7 @@ $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
# If you modify depsver.mf, please make the changes to the master
# copy, the one in sntp is copied by the bootstrap script from it.
#
# This comment block follows rather than leads the related code so that
# This comment block follows rather than leads the related rules so that
# it stays with it in the generated Makefile.in and Makefile.
#

View File

@ -171,12 +171,7 @@
/* Zyfer GPStarplus */
#undef CLOCK_ZYFER
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
#undef CRAY_STACKSEG_END
/* Define to 1 if using `alloca.c'. */
/* Define to 1 if using 'alloca.c'. */
#undef C_ALLOCA
/* Enable debugging code? */
@ -299,6 +294,9 @@
/* use old autokey session key behavior? */
#undef DISABLE_BUG3527_FIX
/* Disable debug assertion on OOB KoD RATE value? */
#undef DISABLE_BUG3767_FIX
/* synch TODR hourly? */
#undef DOSYNCTODR
@ -317,6 +315,9 @@
/* Enable CMAC support? */
#undef ENABLE_CMAC
/* auto-instantiate missing PPS devices on Linux */
#undef ENABLE_MAGICPPS
/* nls support in libopts */
#undef ENABLE_NLS
@ -332,11 +333,10 @@
/* via __adjtimex */
#undef HAVE_ADJTIMEX
/* Define to 1 if you have `alloca', as a function or macro. */
/* Define to 1 if you have 'alloca', as a function or macro. */
#undef HAVE_ALLOCA
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
/* Define to 1 if <alloca.h> works. */
#undef HAVE_ALLOCA_H
/* Define to 1 if you have the `arc4random_buf' function. */
@ -372,6 +372,9 @@
/* Define to 1 if you have the `clock_settime' function. */
#undef HAVE_CLOCK_SETTIME
/* Define to 1 if you have the `closefrom' function. */
#undef HAVE_CLOSEFROM
/* Define to 1 if you have the <cthreads.h> header file. */
#undef HAVE_CTHREADS_H
@ -418,6 +421,9 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `fdopendir' function. */
#undef HAVE_FDOPENDIR
/* Define to 1 if you have the `finite' function. */
#undef HAVE_FINITE
@ -433,6 +439,12 @@
/* Define to 1 if you have the `fstat' function. */
#undef HAVE_FSTAT
/* Define to 1 if you have the `fstatat' function. */
#undef HAVE_FSTATAT
/* Define to 1 if we have realpath() that supports NULL as the 2nd argument */
#undef HAVE_FUNC_POSIX_REALPATH
/* Define to 1 if you have the `getbootfile' function. */
#undef HAVE_GETBOOTFILE
@ -553,7 +565,7 @@
/* Define to 1 if the system has the type `long long'. */
#undef HAVE_LONG_LONG
/* Define to 1 if the system has the type 'long long int'. */
/* Define to 1 if the system has the type `long long int'. */
#undef HAVE_LONG_LONG_INT
/* if you have SunOS LWP package */
@ -592,6 +604,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <minix/config.h> header file. */
#undef HAVE_MINIX_CONFIG_H
/* Define to 1 if you have the `mkstemp' function. */
#undef HAVE_MKSTEMP
@ -670,6 +685,9 @@
/* if you have NT Threads */
#undef HAVE_NT_THREADS
/* Define to 1 if you have the `openat' function. */
#undef HAVE_OPENAT
/* Define to 1 if you have the <openssl/cmac.h> header file. */
#undef HAVE_OPENSSL_CMAC_H
@ -868,6 +886,9 @@
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
@ -883,7 +904,7 @@
/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
/* Define to 1 if you have the `strerror_r' function. */
/* Define if you have `strerror_r'. */
#undef HAVE_STRERROR_R
/* Define to 1 if you have the <strings.h> header file. */
@ -1179,7 +1200,7 @@
/* deviant sigwait? */
#undef HAVE_UNIXWARE_SIGWAIT
/* Define to 1 if the system has the type 'unsigned long long int'. */
/* Define to 1 if the system has the type `unsigned long long int'. */
#undef HAVE_UNSIGNED_LONG_LONG_INT
/* Define to 1 if you have the `updwtmp' function. */
@ -1566,7 +1587,9 @@
STACK_DIRECTION = 0 => direction of growth unknown */
#undef STACK_DIRECTION
/* Define to 1 if you have the ANSI C header files. */
/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#undef STDC_HEADERS
/* Step, then slew the clock? */
@ -1596,7 +1619,8 @@
/* Is K_TICK_NAME in nanoseconds? */
#undef TICK_NANO
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. This
macro is obsolete. */
#undef TIME_WITH_SYS_TIME
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
@ -1627,21 +1651,87 @@ typedef unsigned int uintptr_t;
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
/* Enable general extensions on macOS. */
#ifndef _DARWIN_C_SOURCE
# undef _DARWIN_C_SOURCE
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Enable threading extensions on Solaris. */
/* Enable X/Open compliant socket functions that do not require linking
with -lxnet on HP-UX 11.11. */
#ifndef _HPUX_ALT_XOPEN_SOCKET_API
# undef _HPUX_ALT_XOPEN_SOCKET_API
#endif
/* Identify the host operating system as Minix.
This macro does not affect the system headers' behavior.
A future release of Autoconf may stop defining this macro. */
#ifndef _MINIX
# undef _MINIX
#endif
/* Enable general extensions on NetBSD.
Enable NetBSD compatibility extensions on Minix. */
#ifndef _NETBSD_SOURCE
# undef _NETBSD_SOURCE
#endif
/* Enable OpenBSD compatibility extensions on NetBSD.
Oddly enough, this does nothing on OpenBSD. */
#ifndef _OPENBSD_SOURCE
# undef _OPENBSD_SOURCE
#endif
/* Define to 1 if needed for POSIX-compatible behavior. */
#ifndef _POSIX_SOURCE
# undef _POSIX_SOURCE
#endif
/* Define to 2 if needed for POSIX-compatible behavior. */
#ifndef _POSIX_1_SOURCE
# undef _POSIX_1_SOURCE
#endif
/* Enable POSIX-compatible threading on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
# undef __STDC_WANT_IEC_60559_BFP_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
# undef __STDC_WANT_IEC_60559_DFP_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
# undef __STDC_WANT_IEC_60559_TYPES_EXT__
#endif
/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
#ifndef __STDC_WANT_LIB_EXT2__
# undef __STDC_WANT_LIB_EXT2__
#endif
/* Enable extensions specified by ISO/IEC 24747:2009. */
#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
# undef __STDC_WANT_MATH_SPEC_FUNCS__
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
/* Enable X/Open extensions. Define to 500 only if necessary
to make mbstate_t available. */
#ifndef _XOPEN_SOURCE
# undef _XOPEN_SOURCE
#endif
@ -1675,16 +1765,6 @@ typedef unsigned int uintptr_t;
/* routine worker child proc uses to exit. */
#undef WORKER_CHILD_EXIT
/* Define to 1 if on MINIX. */
#undef _MINIX
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#undef _POSIX_1_SOURCE
/* Define to 1 if you need to in order for `stat' and other things to work. */
#undef _POSIX_SOURCE
/* enable thread safety */
#undef _REENTRANT
@ -1700,7 +1780,8 @@ typedef unsigned int uintptr_t;
/* Are we _special_? */
#undef __APPLE_USE_RFC_3542
/* Define to 1 if type `char' is unsigned and you are not using gcc. */
/* Define to 1 if type `char' is unsigned and your compiler does not
predefine this macro. */
#ifndef __CHAR_UNSIGNED__
# undef __CHAR_UNSIGNED__
#endif
@ -1733,7 +1814,7 @@ typedef unsigned int uintptr_t;
/* Define to `long int' if <sys/types.h> does not define. */
#undef off_t
/* Define to `int' if <sys/types.h> does not define. */
/* Define as a signed integer type capable of holding a process identifier. */
#undef pid_t
/* Define to `unsigned int' if <sys/types.h> does not define. */

17158
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -5,9 +5,9 @@ AC_PREREQ([2.68])
AC_INIT(
[ntp],
[VERSION_NUMBER],
[http://bugs.ntp.org./],
[https://bugs.ntp.org/],
[],
[http://www.ntp.org./]dnl
[https://www.ntp.org/]dnl
)
AC_CONFIG_MACRO_DIR([sntp/m4])
AC_CONFIG_AUX_DIR([sntp/libevent/build-aux])
@ -35,14 +35,14 @@ AC_PRESERVE_HELP_ORDER
# the date YYYYMMDD optionally with -HHMM if there is more than one
# bump in a day.
ntp_configure_cache_version=20120806
ntp_configure_cache_version=20230326
# When the cache version of config.cache and configure do not
# match, NTP_CACHEVERSION will flush the cache.
NTP_CACHEVERSION([main], [$ntp_configure_cache_version])
AM_INIT_AUTOMAKE([1.15 foreign -Wall -Wno-gnu])
AM_INIT_AUTOMAKE([1.15 foreign subdir-objects -Wall -Wno-gnu])
AM_SILENT_RULES([yes])
@ -64,8 +64,6 @@ ntp_jupiter_ok=${ntp_jupiter_ok=no}
NTP_PROG_CC
NTP_COMPILER
dnl # Do we need CXX for anything besides google test?
dnl AC_PROG_CXX
AC_PROG_YACC
dnl AC_PROG_CC_C_O # called by NTP_COMPILER
AX_C99_STRUCT_INIT
@ -76,11 +74,7 @@ NTP_VPATH_HACK dnl used only by ntpd/Makefile.am
NTP_LOCINFO([sntp]) dnl takes over from NTP_BINDIR, in NTP_LIBNTP
dnl AM_PROG_AR req. automake 1.12
m4_ifdef(
[AM_PROG_AR],
[AM_PROG_AR]
)
AM_PROG_AR
# So far, the only shared library we might use is libopts.
# It's a small library - we might as well use a static version of it.
@ -403,7 +397,7 @@ case "$ac_cv_header_stdatomic_h" in
[[
atomic_thread_fence(memory_order_seq_cst);
]]
)]
)],
[ntp_cv_func_atomic_thread_fence=yes],
[ntp_cv_func_atomic_thread_fence=no]
)]
@ -479,7 +473,7 @@ case "$have_adjtimex" in
struct nlist n;
n.n_un.n_name = 0;
]]
)]
)],
[ntp_cv_struct_nlist_n_un=yes],
[ntp_cv_struct_nlist_n_un=no]
)]
@ -855,7 +849,9 @@ AC_CHECK_FUNCS(
)]
)
AC_CHECK_FUNCS([fnmatch getbootfile getuid getrusage nanosleep strsignal])
AC_CHECK_FUNCS([fnmatch getbootfile getuid getrusage nanosleep strsignal ]dnl
[strsignal closefrom getdtablesize])
# kvm_open() is only used by tickadj. Also see above.
case "$ac_cv_header_kvm_h" in
@ -900,6 +896,7 @@ case "$host" in
;;
esac
AC_CHECK_FUNCS([nice plock pututline pututxline readlink rtprio])
NTP_FUNC_REALPATH
case "$host" in
*-*-aix[[4-9]]*)
# XXX only verified thru AIX6.
@ -1109,7 +1106,7 @@ AC_CACHE_CHECK(
[[
extern int syscall (int, ...);
]]
)]
)],
[ntp_cv_decl_syscall=yes],
[ntp_cv_decl_syscall=no]
)]
@ -4211,6 +4208,24 @@ case "$ans" in
esac
AC_MSG_CHECKING([if we want a debug assert on an OOB KoD RATE value])
AC_ARG_ENABLE(
[bug3767-fix],
[AS_HELP_STRING(
[--enable-bug3767-fix],
[+ Disable debug assertion on OOB KoD RATE value]
)],
[ans=$enableval],
[ans=yes]
)
AC_MSG_RESULT([$ans])
case "$ans" in
no)
AC_DEFINE([DISABLE_BUG3767_FIX], [1],
[Disable debug assertion on OOB KoD RATE value?])
esac
AC_MSG_CHECKING([if we should use the IRIG sawtooth filter])
case "$host" in
@ -4295,6 +4310,26 @@ case "$ntp_signd_path" in
;;
esac
dnl check for 'magic pps' for Linux
AC_MSG_CHECKING([if we want 'magic' PPS support])
AC_ARG_ENABLE(
[magicpps],
[AS_HELP_STRING(
[--enable-magicpps],
[+ try to auto-instantiate PPS devices on Linux]
)],
[ans=$enableval],
[ans=yes]
)
AC_MSG_RESULT([$ans])
case "$ans" in
yes)
AC_DEFINE([ENABLE_MAGICPPS], [1],
[auto-instantiate missing PPS devices on Linux])
AC_CHECK_FUNCS([openat fdopendir fstatat])
;;
esac
AC_CHECK_HEADERS([libscf.h])
LSCF=
case "$ac_cv_header_libscf_h" in
@ -4399,11 +4434,6 @@ AC_MSG_RESULT([$ntp_ok])
NTP_UNITYBUILD
dnl gtest is needed for our tests subdirs. It would be nice if we could
dnl require a C++ compiler only if we will use gtest, but AC_PROG_CXX
dnl can't be conditionalized.
NTP_GOOGLETEST
NTP_PROBLEM_TESTS
###

View File

@ -1 +1 @@
Fri Dec 30 11:24:57 UTC 2011
Mon Jan 16 09:26:08 UTC 2023

View File

@ -2,9 +2,9 @@ $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
@[ -f $@ ] || \
cp $(top_srcdir)/deps-ver $@
@[ -w $@ ] || \
chmod ug+w $@
chmod u+w $@
@cmp $(top_srcdir)/deps-ver $@ > /dev/null || ( \
$(MAKE) $(AM_MAKEFLAGS) clean && \
$(MAKE) $(AM_MAKEFLAGS) clean && \
echo -n "Prior $(subdir)/$(DEPDIR) version " && \
cat $@ && \
rm -rf $(DEPDIR) && \
@ -22,7 +22,7 @@ $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
echo -n "Cleaned $(subdir)/$(DEPDIR) version " && \
cat $(top_srcdir)/deps-ver \
)
cp $(top_srcdir)/deps-ver $@
$(AM_V_at)cp $(top_srcdir)/deps-ver $@
.deps-ver: $(top_srcdir)/deps-ver
@[ ! -d $(DEPDIR) ] || $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/deps-ver
@ -30,6 +30,7 @@ $(DEPDIR)/deps-ver: $(top_srcdir)/deps-ver
BUILT_SOURCES += .deps-ver
CLEANFILES += .deps-ver
DISTCLEANFILES += $(DEPDIR)/deps-ver
#
# depsver.mf included in Makefile.am for directories with .deps
@ -55,6 +56,6 @@ CLEANFILES += .deps-ver
# If you modify depsver.mf, please make the changes to the master
# copy, the one in sntp is copied by the bootstrap script from it.
#
# This comment block follows rather than leads the related code so that
# This comment block follows rather than leads the related rules so that
# it stays with it in the generated Makefile.in and Makefile.
#

View File

@ -135,13 +135,14 @@
Ordinarily, the <tt>ntp.keys</tt> file is generated by
the <tt><a href="keygen.html">ntp-keygen</a></tt> program, but it can
be constructed and edited using an ordinary text editor.</p>
<p> Each line of the keys file consists of three or four fields: a key
ID in the range 1 to 65,535, inclusive, a key type, a message digest
key consisting of a printable ASCII string less than 40 characters or
a 40-character hex digit string, and an optional comma-separated list
of IPs that are allowed to serve time. If the OpenSSL library is
installed, the key type can be any message digest algorithm supported
by the library. If the OpenSSL library is not installed, the only
<p> Each line of the keys file consists of three or four fields: a
key ID in the range 1 to 65,535, inclusive, a key type, a
message digest key consisting of a printable ASCII string up to
20 characters or a hex digit string with more than 20
characters, and an optional comma-separated list of IPs that are
allowed to serve time. If the OpenSSL library is installed, the
key type can be any message digest algorithm supported by the
library. If the OpenSSL library is not installed, the only
permitted key type is MD5.</p>
<table>
<caption style="caption-side: bottom;">

View File

@ -68,6 +68,45 @@
</dd>
</dl>
</dd>
<dt id="device"><tt>device 127.127.<i>t.u</i> [timedata <i>devpath</i>] [ppsdata <i>devpath</i>]</tt></dt>
<dd>
This command can be used to specify the devices a reference
clocks should use. Every clock has a special hard-coded builtin
name to use, and while it is possible to make a symlink from the
expected name to the real device, doing so is not always
convenient. On some platforms or setups it is much easier to
specify the real device name in <i>ntpd</i>'s configuration file.
</dd><dd>
Note: It is <i>not</i> necessary to specify device names
in the configuration file; in such a case the builtin name will be
used. But once a device name is given, it will be used as
specified. There's no fallback in case of errors.
</dd><dd>
The arguments are:
<dl>
<dt><tt>timedata <i>devpath</i></tt></dt>
<dd>
Defines the device that provides the time code data stream;
for e.g. NMEA, <i>devpath</i> could be "<tt>/dev/ttyS7</tt>" on a
POSIX-like system or "<tt>\\.\COM4</tt>" for another widely used OS.
</dd>
<dt><tt>ppsdata <i>devpath</i></tt></dt>
<dd>
Defines the device that provides the PPS timing stream. By
default, the time data stream is expected to be able to
provide the PPS data, too. (Proper wiring and hardware
assumed, of course.) This is true for all OSes that implement
the PPS API as originally designed for BSD variants.
<p/>
But on some hardware the PPS signal cannot not delivered to
the UART that handles the serial data; instead it might
be routed to a GPIO pin, and that means that we need a
way to define the device where the PPS data can be acquired
from. The <tt>ppsdata</tt> definition provides support for such
use cases.
</dd>
</dl>
</dd>
</dl>
<hr>
<script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>

View File

@ -9,7 +9,7 @@
<h3>Copyright Notice</h3>
<img src="pic/sheepb.jpg" alt="jpg" align="left"> "Clone me," says Dolly sheepishly.
<p>Last update:
<!-- #BeginDate format:En2m -->4-Feb-2020 23:47<!-- #EndDate -->
<!-- #BeginDate format:En2m -->2-Mar-2023 05:21<!-- #EndDate -->
UTC</p>
<br clear="left">
</p>
@ -34,11 +34,11 @@
* *
***********************************************************************
</pre>
<p>Content starting in 2011 from Harlan Stenn, Danny Mayer, and Martin Burnicki is:</p>
<p>Content starting in 2011 from Harlan Stenn, Juergen Perlinger, Dave Hart, Danny Mayer, Martin Burnicki, and possibly others is:</p>
<pre>
***********************************************************************
* *
* Copyright (c) Network Time Foundation 2011-2020 *
* Copyright (c) Network Time Foundation 2011-2023 *
* *
* All Rights Reserved *
* *
@ -82,12 +82,13 @@
<li><a href="mailto:%20reg@dwf.com">Reg Clemens &lt;reg@dwf.com&gt;</a> Oncore driver (Current maintainer)</li>
<li><a href="mailto:%20clift@ml.csiro.au">Steve Clift &lt;clift@ml.csiro.au&gt;</a> OMEGA clock driver</li>
<li><a href="mailto:%20casey@csc.co.za">Casey Crellin &lt;casey@csc.co.za&gt;</a> vxWorks (Tornado) port and help with target configuration</li>
<li><a href="mailto:%20phdm@macqel.be">Philippe De Muyter &lt;phdm@macqel.be&gt;</a> Wharton reference clock driver, sysV68 and AIX modifications.</li>
<li><a href="mailto:%20Sven_Dietrich@trimble.COM">Sven Dietrich &lt;sven_dietrich@trimble.com&gt;</a> Palisade reference clock driver, NT adj. residuals, integrated Greg's Winnt port.</li>
<li><a href="mailto:%20dundas@salt.jpl.nasa.gov">John A. Dundas III &lt;dundas@salt.jpl.nasa.gov&gt;</a> Apple A/UX port</li>
<li><a href="mailto:%20duwe@immd4.informatik.uni-erlangen.de">Torsten Duwe &lt;duwe@immd4.informatik.uni-erlangen.de&gt;</a> Linux port</li>
<li><a href="mailto:%20dennis@mrbill.canet.ca">Dennis Ferguson &lt;dennis@mrbill.canet.ca&gt;</a> foundation code for NTP Version 2 as specified in RFC-1119</li>
<li><a href="mailto:%20jhay@icomtek.csir.co.za">John Hay &lt;jhay@icomtek.csir.co.za&gt;</a> IPv6 support and testing</li>
<li><a href="mailto:%20davehart@davehart.com">Dave Hart &lt;davehart@davehart.com&gt;</a> General maintenance, Windows port interpolation rewrite</li>
<li><a href="mailto:%20davehart@gmail.com">Dave Hart &lt;davehart@gmail.com&gt;</a> General maintenance, IPv6 cleanup, Windows PPSAPI</li>
<li><a href="mailto:%20neoclock4x@linum.com">Claas Hilbrecht &lt;neoclock4x@linum.com&gt;</a> NeoClock4X clock driver</li>
<li><a href="mailto:%20glenn@herald.usask.ca">Glenn Hollinger &lt;glenn@herald.usask.ca&gt;</a> GOES clock driver</li>
<li><a href="mailto:%20iglesias@uci.edu">Mike Iglesias &lt;iglesias@uci.edu&gt;</a> DEC Alpha port</li>

View File

@ -13,7 +13,7 @@
<body>
<h3>Generic NMEA GPS Receiver</h3>
<p>Last update:
<!-- #BeginDate format:En2m -->13-Jan-2020 07:12<!-- #EndDate -->
<!-- #BeginDate format:En2m -->17-Oct-2020 16:00<!-- #EndDate -->
UTC</p>
<hr>
<h4>Synopsis</h4>
@ -350,6 +350,15 @@
See <a href="#datetrust">below</a>. <strong>Caveat:</strong>
This (hitherto undocumented) bit has moved!
</td>
</tr><tr>
<td align="center">19</td>
<td align="center">524288</td>
<td align="center">0x80000</td>
<td>Ignore receiver status, assume time is always good as long
as it is present at all. A possible option for receivers
with a good hold-over characteristic, but most likely
harmful in general. Use at own risk.
</td>
</tr>
</tbody></table>

0
html/drivers/driver44.html Executable file → Normal file
View File

View File

@ -92,11 +92,11 @@
<br><h4>Naming a Device</h4>
<p>
The <i>GPSD</i> driver uses the same device name as the NMEA
driver, namely <tt>/dev/gps<i>u</i></tt>. There is a simple
reason for that: While the NMEA driver and the <i>GPSD</i>
driver can be active at the same time <b>for different
devices</b>, they cannot access the same device at a
By default, the <i>GPSD</i> driver uses the same device name as
the NMEA driver, namely <tt>/dev/gps<i>u</i></tt>. There is a
simple reason for that: While the NMEA driver and
the <i>GPSD</i> driver can be active at the same time <b>for
different devices</b>, they cannot access the same device at a
time. Having the same name helps on that. It also eases
migration from using NMEA directly to using <i>GPSD</i>, as no
new links etc need to be created.
@ -110,11 +110,18 @@
identification. This makes the migration from the built-in NMEA
driver a bit easier.
</p>
<p>
The driver also honors <tt>device</tt> statements for
the <tt>timedata</tt> channel. (PPS is handled
inside <i>GPSD</i>, so there's no need for that.) This permits a
more natural way to specify the link between <i>GPSD</i>
and <i>NTPD</i>: Simply name the device as it was given
to <i>GPSD</i>.
</p>
<p><b>Note:</b> <i>GPSD</i> (as of version 3.10) cannot use kernel
mode PPS on devices that are hot-plugged. This would require to
attach the PPS line discipline to the character special file,
which is not possible when running with root privileges already
dropped. This is not likely to change in the future.
mode PPS on devices that are hot-plugged or activated on demand.
This is not likely to change in the future. Have a look
at <i>GPSD</i>'s <tt>-n</tt> (<i>nowait</i>) option.
</p>
<!-- --------------------------------------------------------- -->
@ -168,7 +175,7 @@
120s. Then it reverts to STI-only operation until the PPS
is stable again for 40s, when strict mode is engaged
again.
<br><br><b>Important Notice: This is an expiremental
<br><br><b>Important Notice: This is an experimental
feature!</b><br> Switching between strict and STI-only
mode will cause changes in offset and jitter. Use this
mode only if STI-only works fairly well with your setup,
@ -209,7 +216,7 @@
primary clock unit (u mod 128). A secondary unit processes only
the PPS data from <i>GPSD</i> and needs the corresponding master
unit to work<a href="#fn1" name="fn1bl"><sup>1</sup></a>. Use
the 'noselect' keyword on the primary unit if you are not
the '<tt>noselect</tt>' keyword on the primary unit if you are not
interested in its data.
</p><p>The secondary unit employs the usual precautions before
feeding clock samples:</p>
@ -225,7 +232,7 @@
only be used if the GPS receiver can be trusted for the quality
of its PPS signal<a href="fn2"
name="fn2bl"><sup>2</sup></a>. The PPS flag gets cleared if no
PPS records can be aquired for some time. The unit also flushes
PPS records can be acquired for some time. The unit also flushes
the sample buffer at this point to avoid the use of stale PPS
data.</p>
<p><b>Attention:</b> This unit uses its own PPS fudge value

View File

@ -110,9 +110,7 @@
For the JJY driver (type 40 mode 100 - 180), the argument is one telephone number used to dial the telephone JJY service.
The Hayes command ATDT&nbsp;is normally prepended to the number, which can contain other modem control codes as well.</dd>
<dt id="pollskewlist"
><tt>pollskewlist</tt> <tt>[</tt><i>poll</i> <i>value</i><tt>
| </tt><i>value</i><tt>]</tt> <tt>...</tt> <tt>[default </tt><i>value</i><tt>
| </tt><i>value</i><tt>]</tt></dt>
><tt>pollskewlist</tt> <tt>[</tt><i>poll</i> <i>early late</i><tt>]</tt> <tt>...</tt> <tt>[default </tt><i>early late</i><tt>]</tt></dt>
<dd>Enable skewing of our poll requests to our servers.
<i>poll</i>
is a number between 3 and 17 inclusive, identifying a specific poll interval.
@ -123,9 +121,8 @@ a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
<i>early</i> specifies how early the poll may start, while
<i>late</i> specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.</dd>
<dt id="reset"><tt>reset [allpeers] [auth] [ctl] [io] [mem] [sys] [timer]</tt></dt>
<dd>Reset one or more groups of counters maintained by ntpd and exposed by <tt>ntpq</tt> and <tt>ntpdc</tt>.</dd>

View File

@ -75,7 +75,8 @@
<dt><tt>quit</tt></dt>
<dd>Exit <tt>ntpdc</tt>.</dd>
<dt><tt>passwd</tt></dt>
<dd>This command prompts you to type in a password (which will not be echoed) which will be used to authenticate configuration requests. The password must correspond to the key configured for use by the NTP server for this purpose if such requests are to be successful.</dd>
<dd>This command prompts you to type in a password (which will not be echoed) which will be used to authenticate configuration requests. The password must correspond to the key configured for use by the NTP server for this purpose if such requests are to be successful.
It follows the same rules as a password entry in the keys file of <tt>ntpd</tt>.</dd>
<dt><tt>timeout <i>milliseconds</i></tt></dt>
<dd>Specify a timeout period for responses to server queries. The default is about 8000 milliseconds. Note that since <tt>ntpdc</tt> retries each query once after a timeout, the total waiting time for a timeout will be twice the timeout value set.</dd>
</dl>

View File

@ -75,7 +75,8 @@
<dt id="ntpversion"><tt>ntpversion 1 | 2 | 3 | 4</tt></dt>
<dd>Sets the NTP version number which <tt>ntpq</tt> claims in packets. Defaults to 2, Note that mode-6 control messages (and modes, for that matter) didn't exist in NTP version 1.</dd>
<dt id="passwd"><tt>passwd</tt></dt>
<dd>This command prompts for a password to authenticate requests. The password must correspond to the key ID configured in <tt>ntp.conf</tt> for this purpose.</dd>
<dd>This command prompts for a password to authenticate requests. The password must correspond to the key ID configured in <tt>ntp.conf</tt> for this purpose.
It follows the same rules as a password entry in the keys file of <tt>ntpd</tt>.</dd>
<dt id="quit"><tt>quit</tt></dt>
<dd>Exit <tt>ntpq</tt>.</dd>
<dt id="raw"><tt>raw</tt></dt>

View File

@ -1,5 +1,6 @@
document.write("<p>Reference Clock Commands and Options</p><ul>\
<li class='inline'><a href='clockopt.html#fudge'>fudge - specify fudge parameters</a><br>\
<li class='inline'><a href='clockopt.html#device'>device - specify I/O and PPS device(s) for reference clock</a><br>\
<li class='inline'><a href='clockopt.html#server'>server - specify reference clock server</a><br>\
<li class='inline'><a href='comdex.html'>Command Index</a></li>\
</ul>")

View File

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -108,7 +108,6 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_debug.m4 \
$(top_srcdir)/sntp/m4/ntp_dir_sep.m4 \
$(top_srcdir)/sntp/m4/ntp_facilitynames.m4 \
$(top_srcdir)/sntp/m4/ntp_googletest.m4 \
$(top_srcdir)/sntp/m4/ntp_harden.m4 \
$(top_srcdir)/sntp/m4/ntp_ipv6.m4 \
$(top_srcdir)/sntp/m4/ntp_lib_m.m4 \
@ -128,6 +127,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
$(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/realpath.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@ -173,7 +173,7 @@ am__recursive_targets = \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
distdir
distdir distdir-am
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
@ -191,8 +191,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in README
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@ -238,6 +236,7 @@ CALC_TICKADJ_MS = @CALC_TICKADJ_MS@
CALC_TICKADJ_NI = @CALC_TICKADJ_NI@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_NOFORMAT = @CC_NOFORMAT@
CFLAGS = @CFLAGS@
CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@
CFLAGS_NTP = @CFLAGS_NTP@
@ -247,6 +246,8 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPFLAGS_LIBEVENT = @CPPFLAGS_LIBEVENT@
CPPFLAGS_NTP = @CPPFLAGS_NTP@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DCFD = @DCFD@
DEFS = @DEFS@
@ -259,14 +260,10 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EDITLINE_LIBS = @EDITLINE_LIBS@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
GTEST_CONFIG = @GTEST_CONFIG@
GTEST_CPPFLAGS = @GTEST_CPPFLAGS@
GTEST_CXXFLAGS = @GTEST_CXXFLAGS@
GTEST_LDFLAGS = @GTEST_LDFLAGS@
GTEST_LIBS = @GTEST_LIBS@
HAVE_INLINE = @HAVE_INLINE@
HAVE_LEAPSMEARINTERVAL = @HAVE_LEAPSMEARINTERVAL@
HAVE_RLIMIT_MEMLOCK = @HAVE_RLIMIT_MEMLOCK@
@ -477,6 +474,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@ -589,8 +587,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@ -706,8 +704,10 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir: $(DISTFILES)
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \

0
include/icom.h Executable file → Normal file
View File

View File

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -108,7 +108,6 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_debug.m4 \
$(top_srcdir)/sntp/m4/ntp_dir_sep.m4 \
$(top_srcdir)/sntp/m4/ntp_facilitynames.m4 \
$(top_srcdir)/sntp/m4/ntp_googletest.m4 \
$(top_srcdir)/sntp/m4/ntp_harden.m4 \
$(top_srcdir)/sntp/m4/ntp_ipv6.m4 \
$(top_srcdir)/sntp/m4/ntp_lib_m.m4 \
@ -128,6 +127,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
$(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/realpath.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@ -175,8 +175,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
@ -196,6 +194,7 @@ CALC_TICKADJ_MS = @CALC_TICKADJ_MS@
CALC_TICKADJ_NI = @CALC_TICKADJ_NI@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_NOFORMAT = @CC_NOFORMAT@
CFLAGS = @CFLAGS@
CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@
CFLAGS_NTP = @CFLAGS_NTP@
@ -205,6 +204,8 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPFLAGS_LIBEVENT = @CPPFLAGS_LIBEVENT@
CPPFLAGS_NTP = @CPPFLAGS_NTP@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DCFD = @DCFD@
DEFS = @DEFS@
@ -217,14 +218,10 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EDITLINE_LIBS = @EDITLINE_LIBS@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
GTEST_CONFIG = @GTEST_CONFIG@
GTEST_CPPFLAGS = @GTEST_CPPFLAGS@
GTEST_CXXFLAGS = @GTEST_CXXFLAGS@
GTEST_LDFLAGS = @GTEST_LDFLAGS@
GTEST_LIBS = @GTEST_LIBS@
HAVE_INLINE = @HAVE_INLINE@
HAVE_LEAPSMEARINTERVAL = @HAVE_LEAPSMEARINTERVAL@
HAVE_RLIMIT_MEMLOCK = @HAVE_RLIMIT_MEMLOCK@
@ -435,6 +432,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@ -469,8 +467,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@ -539,8 +537,10 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir: $(DISTFILES)
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \

View File

@ -759,6 +759,7 @@ struct pkt {
#define LOOP_CODEC 13 /* set audio codec frequency */
#define LOOP_LEAP 14 /* insert leap after second 23:59 */
#define LOOP_TICK 15 /* sim. low precision clock */
#define LOOP_NOFREQ 16 /* undo a previos LOOP_FREQ */
/*
* Configuration items for the stats printer

View File

@ -234,6 +234,7 @@ struct config_tree_tag {
restrict_fifo * restrict_opts;
addr_opts_fifo *fudge;
addr_opts_fifo *device;
attr_val_fifo * rlimit;
attr_val_fifo * tinker;
attr_val_fifo * enable_opts;

View File

@ -195,9 +195,9 @@ typedef u_int32 u_fp;
do { \
int32 add_f = (int32)(f); \
if (add_f >= 0) \
M_ADD((r_i), (r_f), 0, (uint32)( add_f)); \
M_ADD((r_i), (r_f), 0, (u_int32)( add_f)); \
else \
M_SUB((r_i), (r_f), 0, (uint32)(-add_f)); \
M_SUB((r_i), (r_f), 0, (u_int32)(-add_f)); \
} while(0)
#define M_ISNEG(v_i) /* v < 0 */ \

View File

@ -5,6 +5,7 @@ void ntp_crypto_srandom(void);
int ntp_crypto_random_buf(void *buf, size_t nbytes);
long ntp_random (void);
double ntp_uurandom(void);
void ntp_srandom (unsigned long);
void ntp_srandomdev (void);
char * ntp_initstate (unsigned long, /* seed for R.N.G. */

View File

@ -213,13 +213,15 @@ struct refclock {
extern int io_addclock (struct refclockio *);
extern void io_closeclock (struct refclockio *);
#define FDWRITE_ERROR ((size_t)-1)
#ifdef REFCLOCK
extern void refclock_buginfo(sockaddr_u *,
struct refclockbug *);
extern void refclock_control(sockaddr_u *,
const struct refclockstat *,
struct refclockstat *);
extern int refclock_open (const char *, u_int, u_int);
extern int refclock_open (const sockaddr_u *srcadr, const char *, u_int, u_int);
extern int refclock_setup (int, u_int, u_int);
extern void refclock_timer (struct peer *);
extern void refclock_transmit(struct peer *);
@ -232,6 +234,10 @@ extern int refclock_samples_expire(struct refclockproc *, int);
extern void refclock_report (struct peer *, int);
extern int refclock_gtlin (struct recvbuf *, char *, int, l_fp *);
extern int refclock_gtraw (struct recvbuf *, char *, int, l_fp *);
extern size_t refclock_write (const struct peer *, const void *, size_t,
const char * what);
extern size_t refclock_fdwrite(const struct peer *, int, const void *, size_t,
const char * what);
extern int indicate_refclock_packet(struct refclockio *,
struct recvbuf *);
extern void process_refclock_packet(struct recvbuf *);
@ -250,6 +256,11 @@ extern int refclock_ppsaugment(
const struct refclock_atom*, l_fp *rcvtime ,
double rcvfudge, double ppsfudge);
extern int ppsdev_reopen(const sockaddr_u *srcadr,
int ttyfd, int ppsfd, const char *ppspath,
int mode, int flags);
extern void ppsdev_close(int ttyfd, int ppsfd);
#endif /* REFCLOCK */
#endif /* NTP_REFCLOCK_H */

View File

@ -40,6 +40,8 @@ extern void setup_logfile (const char *);
extern void errno_to_str(int, char *, size_t);
#endif
extern char * ntp_realpath(const char * fsname);
extern int xvsbprintf(char**, char* const, char const*, va_list) NTP_PRINTF(3, 0);
extern int xsbprintf(char**, char* const, char const*, ...) NTP_PRINTF(3, 4);
@ -67,8 +69,17 @@ extern int xsbprintf(char**, char* const, char const*, ...) NTP_PRINTF(3, 4);
typedef void (*ctrl_c_fn)(void);
/* authkeys.c */
#define AUTHPWD_MAXSECLEN 64 /* max. length of secret blob */
enum AuthPwdEnc {
AUTHPWD_UNSPEC, /* format unspecified, length used for discrimination */
AUTHPWD_PLAIN, /* plain text, used as is */
AUTHPWD_HEX /* hex-encoded string */
};
extern void auth_delkeys (void);
extern int auth_havekey (keyid_t);
extern size_t authdecodepw (u_char *dst, size_t dstlen, const char *src, enum AuthPwdEnc);
extern int authdecrypt (keyid_t, u_int32 *, size_t, size_t);
extern size_t authencrypt (keyid_t, u_int32 *, size_t);
extern int authhavekey (keyid_t);
@ -100,7 +111,7 @@ extern void auth_prealloc_symkeys(int);
extern int ymd2yd (int, int, int);
/* a_md5encrypt.c */
extern int MD5authdecrypt (int, const u_char *, size_t, u_int32 *, size_t, size_t);
extern int MD5authdecrypt (int, const u_char *, size_t, u_int32 *, size_t, size_t, keyid_t);
extern size_t MD5authencrypt (int, const u_char *, size_t, u_int32 *, size_t);
extern void MD5auth_setkey (keyid_t, int, const u_char *, size_t, KeyAccT *c);
extern u_int32 addr2refid (sockaddr_u *);
@ -174,7 +185,7 @@ extern int sockaddr_masktoprefixlen(const sockaddr_u *);
extern const char * socktohost (const sockaddr_u *);
extern int octtoint (const char *, u_long *);
extern u_long ranp2 (int);
extern const char *refnumtoa (sockaddr_u *);
extern const char *refnumtoa (const sockaddr_u *);
extern const char *refid_str (u_int32, int);
extern int decodenetnum (const char *, sockaddr_u *);

View File

@ -168,11 +168,11 @@ typedef unsigned long long u_int64;
/*
* and here the trouble starts: We need a representation with more than
* 64 bits. If a scalar of that size is not available, we need a struct
* 32 bits. If a scalar of that size is not available, we need a struct
* that holds the value in split representation.
*
* To ease the usage a bit, we alwys use a union that is in processor
* byte order and might or might not contain a 64bit scalar.
* byte order and might or might not contain a 64-bit scalar.
*/
#if SIZEOF_SHORT != 2
@ -258,10 +258,11 @@ aligned_ptr(
* Macro to use in otherwise-empty source files to comply with ANSI C
* requirement that each translation unit (source file) contain some
* declaration. This has commonly been done by declaring an unused
* global variable of type int or char. An extern reference to exit()
* serves the same purpose without bloat.
* global variable of type int or char. An extern reference to abs()
* serves the same purpose without bloat. We once used exit() but
* that can produce warnings on systems that declare exit() noreturn.
*/
#define NONEMPTY_TRANSLATION_UNIT extern void exit(int);
#define NONEMPTY_TRANSLATION_UNIT extern int abs(int);
/*
* On Unix struct sock_timeval is equivalent to struct timeval.

View File

@ -483,6 +483,7 @@ extern struct peer *sys_peer; /* current peer */
* Nonspecified system state variables.
*/
extern int sys_bclient; /* we set our time to broadcasts */
extern int sys_mclient; /* we set our time to manycasts */
extern double sys_bdelay; /* broadcast client default delay */
extern int sys_authenticate; /* requre authentication for config */
extern l_fp sys_authdelay; /* authentication delay */

View File

@ -14,7 +14,7 @@
# include "msvc_ssl_autolib.h"
# endif
# endif
# if OPENSSL_VERSION_NUMBER < 0x10100000L
# if OPENSSL_VERSION_NUMBER < 0x10100000L || OPENSSL_VERSION_NUMBER >= 0x10101000L
# include <openssl/applink.c>
# endif
# ifdef _MSC_VER

View File

@ -23,6 +23,6 @@ extern vint64 subv64i32(const vint64 * lhs, int32_t rhs);
extern vint64 subv64u32(const vint64 * lhs, uint32_t rhs);
/* parsing. works like strtoul() or strtoull() */
extern vint64 strtouv64(const char * begp, char ** endp, int base);
extern vint64 strtouv64(char const * begp, char const ** const endp, int base);
#endif /*!defined(VINT64OPS_H)*/

View File

@ -1,6 +1,6 @@
## includes.mf - automake fragment
NTP_INCS = -I$(top_srcdir)/include
NTP_INCS += -I$(top_srcdir)/lib/isc/include
NTP_INCS += -I$(top_srcdir)/lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/include
NTP_INCS += -I$(top_srcdir)/lib/isc/unix/include
NTP_INCS += -I$(top_srcdir)/libntp/lib/isc/include
NTP_INCS += -I$(top_srcdir)/libntp/lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/include
NTP_INCS += -I$(top_srcdir)/libntp/lib/isc/unix/include

View File

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -107,7 +107,6 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_debug.m4 \
$(top_srcdir)/sntp/m4/ntp_dir_sep.m4 \
$(top_srcdir)/sntp/m4/ntp_facilitynames.m4 \
$(top_srcdir)/sntp/m4/ntp_googletest.m4 \
$(top_srcdir)/sntp/m4/ntp_harden.m4 \
$(top_srcdir)/sntp/m4/ntp_ipv6.m4 \
$(top_srcdir)/sntp/m4/ntp_lib_m.m4 \
@ -127,6 +126,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
$(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/realpath.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@ -170,7 +170,7 @@ am__recursive_targets = \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
distdir
distdir distdir-am
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
@ -188,8 +188,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@ -235,6 +233,7 @@ CALC_TICKADJ_MS = @CALC_TICKADJ_MS@
CALC_TICKADJ_NI = @CALC_TICKADJ_NI@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_NOFORMAT = @CC_NOFORMAT@
CFLAGS = @CFLAGS@
CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@
CFLAGS_NTP = @CFLAGS_NTP@
@ -244,6 +243,8 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPFLAGS_LIBEVENT = @CPPFLAGS_LIBEVENT@
CPPFLAGS_NTP = @CPPFLAGS_NTP@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DCFD = @DCFD@
DEFS = @DEFS@
@ -256,14 +257,10 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EDITLINE_LIBS = @EDITLINE_LIBS@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
GTEST_CONFIG = @GTEST_CONFIG@
GTEST_CPPFLAGS = @GTEST_CPPFLAGS@
GTEST_CXXFLAGS = @GTEST_CXXFLAGS@
GTEST_LDFLAGS = @GTEST_LDFLAGS@
GTEST_LIBS = @GTEST_LIBS@
HAVE_INLINE = @HAVE_INLINE@
HAVE_LEAPSMEARINTERVAL = @HAVE_LEAPSMEARINTERVAL@
HAVE_RLIMIT_MEMLOCK = @HAVE_RLIMIT_MEMLOCK@
@ -474,6 +471,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@ -504,8 +502,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@ -621,8 +619,10 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir: $(DISTFILES)
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \

View File

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.15.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2017 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -108,7 +108,6 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_debug.m4 \
$(top_srcdir)/sntp/m4/ntp_dir_sep.m4 \
$(top_srcdir)/sntp/m4/ntp_facilitynames.m4 \
$(top_srcdir)/sntp/m4/ntp_googletest.m4 \
$(top_srcdir)/sntp/m4/ntp_harden.m4 \
$(top_srcdir)/sntp/m4/ntp_ipv6.m4 \
$(top_srcdir)/sntp/m4/ntp_lib_m.m4 \
@ -128,6 +127,7 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
$(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/realpath.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@ -175,8 +175,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in README
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
@ -196,6 +194,7 @@ CALC_TICKADJ_MS = @CALC_TICKADJ_MS@
CALC_TICKADJ_NI = @CALC_TICKADJ_NI@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_NOFORMAT = @CC_NOFORMAT@
CFLAGS = @CFLAGS@
CFLAGS_LIBEVENT = @CFLAGS_LIBEVENT@
CFLAGS_NTP = @CFLAGS_NTP@
@ -205,6 +204,8 @@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPFLAGS_LIBEVENT = @CPPFLAGS_LIBEVENT@
CPPFLAGS_NTP = @CPPFLAGS_NTP@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CYGPATH_W = @CYGPATH_W@
DCFD = @DCFD@
DEFS = @DEFS@
@ -217,14 +218,10 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EDITLINE_LIBS = @EDITLINE_LIBS@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
GTEST_CONFIG = @GTEST_CONFIG@
GTEST_CPPFLAGS = @GTEST_CPPFLAGS@
GTEST_CXXFLAGS = @GTEST_CXXFLAGS@
GTEST_LDFLAGS = @GTEST_LDFLAGS@
GTEST_LIBS = @GTEST_LIBS@
HAVE_INLINE = @HAVE_INLINE@
HAVE_LEAPSMEARINTERVAL = @HAVE_LEAPSMEARINTERVAL@
HAVE_RLIMIT_MEMLOCK = @HAVE_RLIMIT_MEMLOCK@
@ -435,6 +432,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@ -467,8 +465,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@ -537,8 +535,10 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir: $(DISTFILES)
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \

View File

@ -1,5 +0,0 @@
Content-Type: application/X-atf-atffile; version="1"
prop: test-suite = bind9
tp: tests

View File

@ -1,184 +0,0 @@
/*
* 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: atomic.h,v 1.7 2009/04/08 06:48:23 tbox Exp $ */
/*
* This code was written based on FreeBSD's kernel source whose copyright
* follows:
*/
/*-
* Copyright (c) 1998 Doug Rabson
* 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.
*
* 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.
*
* $FreeBSD: src/sys/alpha/include/atomic.h,v 1.18.6.1 2004/09/13 21:52:04 wilko Exp $
*/
#ifndef ISC_ATOMIC_H
#define ISC_ATOMIC_H 1
#include <isc/platform.h>
#include <isc/types.h>
#ifdef ISC_PLATFORM_USEOSFASM
#include <c_asm.h>
#pragma intrinsic(asm)
/*
* This routine atomically increments the value stored in 'p' by 'val', and
* returns the previous value. Memory access ordering around this function
* can be critical, so we add explicit memory block instructions at the
* beginning and the end of it (same for other functions).
*/
static inline isc_int32_t
isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) {
return (asm("mb;"
"1:"
"ldl_l %t0, 0(%a0);" /* load old value */
"mov %t0, %v0;" /* copy the old value */
"addl %t0, %a1, %t0;" /* calculate new value */
"stl_c %t0, 0(%a0);" /* attempt to store */
"beq %t0, 1b;" /* spin if failed */
"mb;",
p, val));
}
/*
* This routine atomically stores the value 'val' in 'p'.
*/
static inline void
isc_atomic_store(isc_int32_t *p, isc_int32_t val) {
(void)asm("mb;"
"1:"
"ldl_l %t0, 0(%a0);" /* load old value */
"mov %a1, %t0;" /* value to store */
"stl_c %t0, 0(%a0);" /* attempt to store */
"beq %t0, 1b;" /* spin if failed */
"mb;",
p, val);
}
/*
* This routine atomically replaces the value in 'p' with 'val', if the
* original value is equal to 'cmpval'. The original value is returned in any
* case.
*/
static inline isc_int32_t
isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) {
return(asm("mb;"
"1:"
"ldl_l %t0, 0(%a0);" /* load old value */
"mov %t0, %v0;" /* copy the old value */
"cmpeq %t0, %a1, %t0;" /* compare */
"beq %t0, 2f;" /* exit if not equal */
"mov %a2, %t0;" /* value to store */
"stl_c %t0, 0(%a0);" /* attempt to store */
"beq %t0, 1b;" /* if it failed, spin */
"2:"
"mb;",
p, cmpval, val));
}
#elif defined (ISC_PLATFORM_USEGCCASM)
static inline isc_int32_t
isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) {
isc_int32_t temp, prev;
__asm__ volatile(
"mb;"
"1:"
"ldl_l %0, %1;" /* load old value */
"mov %0, %2;" /* copy the old value */
"addl %0, %3, %0;" /* calculate new value */
"stl_c %0, %1;" /* attempt to store */
"beq %0, 1b;" /* spin if failed */
"mb;"
: "=&r"(temp), "+m"(*p), "=&r"(prev)
: "r"(val)
: "memory");
return (prev);
}
static inline void
isc_atomic_store(isc_int32_t *p, isc_int32_t val) {
isc_int32_t temp;
__asm__ volatile(
"mb;"
"1:"
"ldl_l %0, %1;" /* load old value */
"mov %2, %0;" /* value to store */
"stl_c %0, %1;" /* attempt to store */
"beq %0, 1b;" /* if it failed, spin */
"mb;"
: "=&r"(temp), "+m"(*p)
: "r"(val)
: "memory");
}
static inline isc_int32_t
isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) {
isc_int32_t temp, prev;
__asm__ volatile(
"mb;"
"1:"
"ldl_l %0, %1;" /* load old value */
"mov %0, %2;" /* copy the old value */
"cmpeq %0, %3, %0;" /* compare */
"beq %0, 2f;" /* exit if not equal */
"mov %4, %0;" /* value to store */
"stl_c %0, %1;" /* attempt to store */
"beq %0, 1b;" /* if it failed, spin */
"2:"
"mb;"
: "=&r"(temp), "+m"(*p), "=&r"(prev)
: "r"(cmpval), "r"(val)
: "memory");
return (prev);
}
#else
#error "unsupported compiler. disable atomic ops by --disable-atomic"
#endif
#endif /* ISC_ATOMIC_H */

View File

@ -1,8 +0,0 @@
# LIBINTERFACE ranges
# 9.6: 50-59, 110-119
# 9.7: 60-79
# 9.8: 80-89
# 9.9: 90-109
LIBINTERFACE = 91
LIBREVISION = 1
LIBAGE = 1

View File

@ -1,136 +0,0 @@
/*
* 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: app_api.c,v 1.5 2009/09/02 23:48:02 tbox Exp $ */
#include <config.h>
#include <unistd.h>
#include <isc/app.h>
#include <isc/magic.h>
#include <isc/mutex.h>
#include <isc/once.h>
#include <isc/util.h>
static isc_mutex_t createlock;
static isc_once_t once = ISC_ONCE_INIT;
static isc_appctxcreatefunc_t appctx_createfunc = NULL;
#define ISCAPI_APPMETHODS_VALID(m) ISC_MAGIC_VALID(m, ISCAPI_APPMETHODS_MAGIC)
static void
initialize(void) {
RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
}
isc_result_t
isc_app_register(isc_appctxcreatefunc_t createfunc) {
isc_result_t result = ISC_R_SUCCESS;
RUNTIME_CHECK(isc_once_do(&once, initialize) == ISC_R_SUCCESS);
LOCK(&createlock);
if (appctx_createfunc == NULL)
appctx_createfunc = createfunc;
else
result = ISC_R_EXISTS;
UNLOCK(&createlock);
return (result);
}
isc_result_t
isc_appctx_create(isc_mem_t *mctx, isc_appctx_t **ctxp) {
isc_result_t result;
LOCK(&createlock);
REQUIRE(appctx_createfunc != NULL);
result = (*appctx_createfunc)(mctx, ctxp);
UNLOCK(&createlock);
return (result);
}
void
isc_appctx_destroy(isc_appctx_t **ctxp) {
REQUIRE(ctxp != NULL && ISCAPI_APPCTX_VALID(*ctxp));
(*ctxp)->methods->ctxdestroy(ctxp);
ENSURE(*ctxp == NULL);
}
isc_result_t
isc_app_ctxstart(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
return (ctx->methods->ctxstart(ctx));
}
isc_result_t
isc_app_ctxrun(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
return (ctx->methods->ctxrun(ctx));
}
isc_result_t
isc_app_ctxsuspend(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
return (ctx->methods->ctxsuspend(ctx));
}
isc_result_t
isc_app_ctxshutdown(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
return (ctx->methods->ctxshutdown(ctx));
}
void
isc_app_ctxfinish(isc_appctx_t *ctx) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
ctx->methods->ctxfinish(ctx);
}
void
isc_appctx_settaskmgr(isc_appctx_t *ctx, isc_taskmgr_t *taskmgr) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
REQUIRE(taskmgr != NULL);
ctx->methods->settaskmgr(ctx, taskmgr);
}
void
isc_appctx_setsocketmgr(isc_appctx_t *ctx, isc_socketmgr_t *socketmgr) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
REQUIRE(socketmgr != NULL);
ctx->methods->setsocketmgr(ctx, socketmgr);
}
void
isc_appctx_settimermgr(isc_appctx_t *ctx, isc_timermgr_t *timermgr) {
REQUIRE(ISCAPI_APPCTX_VALID(ctx));
REQUIRE(timermgr != NULL);
ctx->methods->settimermgr(ctx, timermgr);
}

View File

@ -1,373 +0,0 @@
/*
* 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: base32.c,v 1.6 2009/10/21 01:22:29 each Exp $ */
/*! \file */
#include <config.h>
#include <isc/base32.h>
#include <isc/buffer.h>
#include <isc/lex.h>
#include <isc/region.h>
#include <isc/string.h>
#include <isc/util.h>
#define RETERR(x) do { \
isc_result_t _r = (x); \
if (_r != ISC_R_SUCCESS) \
return (_r); \
} while (0)
/*@{*/
/*!
* These static functions are also present in lib/dns/rdata.c. I'm not
* sure where they should go. -- bwelling
*/
static isc_result_t
str_totext(const char *source, isc_buffer_t *target);
static isc_result_t
mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length);
/*@}*/
static const char base32[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=abcdefghijklmnopqrstuvwxyz234567";
static const char base32hex[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUV=0123456789abcdefghijklmnopqrstuv";
static isc_result_t
base32_totext(isc_region_t *source, int wordlength, const char *wordbreak,
isc_buffer_t *target, const char base[])
{
char buf[9];
unsigned int loops = 0;
if (wordlength >= 0 && wordlength < 8)
wordlength = 8;
memset(buf, 0, sizeof(buf));
while (source->length > 0) {
buf[0] = base[((source->base[0]>>3)&0x1f)]; /* 5 + */
if (source->length == 1) {
buf[1] = base[(source->base[0]<<2)&0x1c];
buf[2] = buf[3] = buf[4] = '=';
buf[5] = buf[6] = buf[7] = '=';
RETERR(str_totext(buf, target));
break;
}
buf[1] = base[((source->base[0]<<2)&0x1c)| /* 3 = 8 */
((source->base[1]>>6)&0x03)]; /* 2 + */
buf[2] = base[((source->base[1]>>1)&0x1f)]; /* 5 + */
if (source->length == 2) {
buf[3] = base[(source->base[1]<<4)&0x10];
buf[4] = buf[5] = buf[6] = buf[7] = '=';
RETERR(str_totext(buf, target));
break;
}
buf[3] = base[((source->base[1]<<4)&0x10)| /* 1 = 8 */
((source->base[2]>>4)&0x0f)]; /* 4 + */
if (source->length == 3) {
buf[4] = base[(source->base[2]<<1)&0x1e];
buf[5] = buf[6] = buf[7] = '=';
RETERR(str_totext(buf, target));
break;
}
buf[4] = base[((source->base[2]<<1)&0x1e)| /* 4 = 8 */
((source->base[3]>>7)&0x01)]; /* 1 + */
buf[5] = base[((source->base[3]>>2)&0x1f)]; /* 5 + */
if (source->length == 4) {
buf[6] = base[(source->base[3]<<3)&0x18];
buf[7] = '=';
RETERR(str_totext(buf, target));
break;
}
buf[6] = base[((source->base[3]<<3)&0x18)| /* 2 = 8 */
((source->base[4]>>5)&0x07)]; /* 3 + */
buf[7] = base[source->base[4]&0x1f]; /* 5 = 8 */
RETERR(str_totext(buf, target));
isc_region_consume(source, 5);
loops++;
if (source->length != 0 && wordlength >= 0 &&
(int)((loops + 1) * 8) >= wordlength)
{
loops = 0;
RETERR(str_totext(wordbreak, target));
}
}
if (source->length > 0)
isc_region_consume(source, source->length);
return (ISC_R_SUCCESS);
}
isc_result_t
isc_base32_totext(isc_region_t *source, int wordlength,
const char *wordbreak, isc_buffer_t *target)
{
return (base32_totext(source, wordlength, wordbreak, target, base32));
}
isc_result_t
isc_base32hex_totext(isc_region_t *source, int wordlength,
const char *wordbreak, isc_buffer_t *target)
{
return (base32_totext(source, wordlength, wordbreak, target,
base32hex));
}
/*%
* State of a base32 decoding process in progress.
*/
typedef struct {
int length; /*%< Desired length of binary data or -1 */
isc_buffer_t *target; /*%< Buffer for resulting binary data */
int digits; /*%< Number of buffered base32 digits */
isc_boolean_t seen_end; /*%< True if "=" end marker seen */
int val[8];
const char *base; /*%< Which encoding we are using */
int seen_32; /*%< Number of significant bytes if non zero */
} base32_decode_ctx_t;
static inline void
base32_decode_init(base32_decode_ctx_t *ctx, int length,
const char base[], isc_buffer_t *target)
{
ctx->digits = 0;
ctx->seen_end = ISC_FALSE;
ctx->seen_32 = 0;
ctx->length = length;
ctx->target = target;
ctx->base = base;
}
static inline isc_result_t
base32_decode_char(base32_decode_ctx_t *ctx, int c) {
char *s;
unsigned int last;
if (ctx->seen_end)
return (ISC_R_BADBASE32);
if ((s = strchr(ctx->base, c)) == NULL)
return (ISC_R_BADBASE32);
last = s - ctx->base;
/*
* Handle lower case.
*/
if (last > 32)
last -= 33;
/*
* Check that padding is contiguous.
*/
if (last != 32 && ctx->seen_32 != 0)
return (ISC_R_BADBASE32);
/*
* Check that padding starts at the right place and that
* bits that should be zero are.
* Record how many significant bytes in answer (seen_32).
*/
if (last == 32 && ctx->seen_32 == 0)
switch (ctx->digits) {
case 0:
case 1:
return (ISC_R_BADBASE32);
case 2:
if ((ctx->val[1]&0x03) != 0)
return (ISC_R_BADBASE32);
ctx->seen_32 = 1;
break;
case 3:
return (ISC_R_BADBASE32);
case 4:
if ((ctx->val[3]&0x0f) != 0)
return (ISC_R_BADBASE32);
ctx->seen_32 = 3;
break;
case 5:
if ((ctx->val[4]&0x01) != 0)
return (ISC_R_BADBASE32);
ctx->seen_32 = 3;
break;
case 6:
return (ISC_R_BADBASE32);
case 7:
if ((ctx->val[6]&0x07) != 0)
return (ISC_R_BADBASE32);
ctx->seen_32 = 4;
break;
}
/*
* Zero fill pad values.
*/
ctx->val[ctx->digits++] = (last == 32) ? 0 : last;
if (ctx->digits == 8) {
int n = 5;
unsigned char buf[5];
if (ctx->seen_32 != 0) {
ctx->seen_end = ISC_TRUE;
n = ctx->seen_32;
}
buf[0] = (ctx->val[0]<<3)|(ctx->val[1]>>2);
buf[1] = (ctx->val[1]<<6)|(ctx->val[2]<<1)|(ctx->val[3]>>4);
buf[2] = (ctx->val[3]<<4)|(ctx->val[4]>>1);
buf[3] = (ctx->val[4]<<7)|(ctx->val[5]<<2)|(ctx->val[6]>>3);
buf[4] = (ctx->val[6]<<5)|(ctx->val[7]);
RETERR(mem_tobuffer(ctx->target, buf, n));
if (ctx->length >= 0) {
if (n > ctx->length)
return (ISC_R_BADBASE32);
else
ctx->length -= n;
}
ctx->digits = 0;
}
return (ISC_R_SUCCESS);
}
static inline isc_result_t
base32_decode_finish(base32_decode_ctx_t *ctx) {
if (ctx->length > 0)
return (ISC_R_UNEXPECTEDEND);
if (ctx->digits != 0)
return (ISC_R_BADBASE32);
return (ISC_R_SUCCESS);
}
static isc_result_t
base32_tobuffer(isc_lex_t *lexer, const char base[], isc_buffer_t *target,
int length)
{
base32_decode_ctx_t ctx;
isc_textregion_t *tr;
isc_token_t token;
isc_boolean_t eol;
base32_decode_init(&ctx, length, base, target);
while (!ctx.seen_end && (ctx.length != 0)) {
unsigned int i;
if (length > 0)
eol = ISC_FALSE;
else
eol = ISC_TRUE;
RETERR(isc_lex_getmastertoken(lexer, &token,
isc_tokentype_string, eol));
if (token.type != isc_tokentype_string)
break;
tr = &token.value.as_textregion;
for (i = 0; i < tr->length; i++)
RETERR(base32_decode_char(&ctx, tr->base[i]));
}
if (ctx.length < 0 && !ctx.seen_end)
isc_lex_ungettoken(lexer, &token);
RETERR(base32_decode_finish(&ctx));
return (ISC_R_SUCCESS);
}
isc_result_t
isc_base32_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length) {
return (base32_tobuffer(lexer, base32, target, length));
}
isc_result_t
isc_base32hex_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length) {
return (base32_tobuffer(lexer, base32hex, target, length));
}
static isc_result_t
base32_decodestring(const char *cstr, const char base[], isc_buffer_t *target) {
base32_decode_ctx_t ctx;
base32_decode_init(&ctx, -1, base, target);
for (;;) {
int c = *cstr++;
if (c == '\0')
break;
if (c == ' ' || c == '\t' || c == '\n' || c== '\r')
continue;
RETERR(base32_decode_char(&ctx, c));
}
RETERR(base32_decode_finish(&ctx));
return (ISC_R_SUCCESS);
}
isc_result_t
isc_base32_decodestring(const char *cstr, isc_buffer_t *target) {
return (base32_decodestring(cstr, base32, target));
}
isc_result_t
isc_base32hex_decodestring(const char *cstr, isc_buffer_t *target) {
return (base32_decodestring(cstr, base32hex, target));
}
static isc_result_t
base32_decoderegion(isc_region_t *source, const char base[], isc_buffer_t *target) {
base32_decode_ctx_t ctx;
base32_decode_init(&ctx, -1, base, target);
while (source->length != 0) {
int c = *source->base;
RETERR(base32_decode_char(&ctx, c));
isc_region_consume(source, 1);
}
RETERR(base32_decode_finish(&ctx));
return (ISC_R_SUCCESS);
}
isc_result_t
isc_base32_decoderegion(isc_region_t *source, isc_buffer_t *target) {
return (base32_decoderegion(source, base32, target));
}
isc_result_t
isc_base32hex_decoderegion(isc_region_t *source, isc_buffer_t *target) {
return (base32_decoderegion(source, base32hex, target));
}
static isc_result_t
str_totext(const char *source, isc_buffer_t *target) {
unsigned int l;
isc_region_t region;
isc_buffer_availableregion(target, &region);
l = strlen(source);
if (l > region.length)
return (ISC_R_NOSPACE);
memcpy(region.base, source, l);
isc_buffer_add(target, l);
return (ISC_R_SUCCESS);
}
static isc_result_t
mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) {
isc_region_t tr;
isc_buffer_availableregion(target, &tr);
if (length > tr.length)
return (ISC_R_NOSPACE);
memcpy(tr.base, base, length);
isc_buffer_add(target, length);
return (ISC_R_SUCCESS);
}

View File

@ -1,252 +0,0 @@
/*
* Copyright (C) 2004, 2005, 2007, 2009 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: base64.c,v 1.34 2009/10/21 23:48:05 tbox Exp $ */
/*! \file */
#include <config.h>
#include <isc/base64.h>
#include <isc/buffer.h>
#include <isc/lex.h>
#include <isc/string.h>
#include <isc/util.h>
#define RETERR(x) do { \
isc_result_t _r = (x); \
if (_r != ISC_R_SUCCESS) \
return (_r); \
} while (0)
/*@{*/
/*!
* These static functions are also present in lib/dns/rdata.c. I'm not
* sure where they should go. -- bwelling
*/
static isc_result_t
str_totext(const char *source, isc_buffer_t *target);
static isc_result_t
mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length);
static const char base64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
/*@}*/
isc_result_t
isc_base64_totext(isc_region_t *source, int wordlength,
const char *wordbreak, isc_buffer_t *target)
{
char buf[5];
unsigned int loops = 0;
if (wordlength < 4)
wordlength = 4;
memset(buf, 0, sizeof(buf));
while (source->length > 2) {
buf[0] = base64[(source->base[0]>>2)&0x3f];
buf[1] = base64[((source->base[0]<<4)&0x30)|
((source->base[1]>>4)&0x0f)];
buf[2] = base64[((source->base[1]<<2)&0x3c)|
((source->base[2]>>6)&0x03)];
buf[3] = base64[source->base[2]&0x3f];
RETERR(str_totext(buf, target));
isc_region_consume(source, 3);
loops++;
if (source->length != 0 &&
(int)((loops + 1) * 4) >= wordlength)
{
loops = 0;
RETERR(str_totext(wordbreak, target));
}
}
if (source->length == 2) {
buf[0] = base64[(source->base[0]>>2)&0x3f];
buf[1] = base64[((source->base[0]<<4)&0x30)|
((source->base[1]>>4)&0x0f)];
buf[2] = base64[((source->base[1]<<2)&0x3c)];
buf[3] = '=';
RETERR(str_totext(buf, target));
isc_region_consume(source, 2);
} else if (source->length == 1) {
buf[0] = base64[(source->base[0]>>2)&0x3f];
buf[1] = base64[((source->base[0]<<4)&0x30)];
buf[2] = buf[3] = '=';
RETERR(str_totext(buf, target));
isc_region_consume(source, 1);
}
return (ISC_R_SUCCESS);
}
/*%
* State of a base64 decoding process in progress.
*/
typedef struct {
int length; /*%< Desired length of binary data or -1 */
isc_buffer_t *target; /*%< Buffer for resulting binary data */
int digits; /*%< Number of buffered base64 digits */
isc_boolean_t seen_end; /*%< True if "=" end marker seen */
int val[4];
} base64_decode_ctx_t;
static inline void
base64_decode_init(base64_decode_ctx_t *ctx, int length, isc_buffer_t *target)
{
ctx->digits = 0;
ctx->seen_end = ISC_FALSE;
ctx->length = length;
ctx->target = target;
}
static inline isc_result_t
base64_decode_char(base64_decode_ctx_t *ctx, int c) {
char *s;
if (ctx->seen_end)
return (ISC_R_BADBASE64);
if ((s = strchr(base64, c)) == NULL)
return (ISC_R_BADBASE64);
ctx->val[ctx->digits++] = s - base64;
if (ctx->digits == 4) {
int n;
unsigned char buf[3];
if (ctx->val[0] == 64 || ctx->val[1] == 64)
return (ISC_R_BADBASE64);
if (ctx->val[2] == 64 && ctx->val[3] != 64)
return (ISC_R_BADBASE64);
/*
* Check that bits that should be zero are.
*/
if (ctx->val[2] == 64 && (ctx->val[1] & 0xf) != 0)
return (ISC_R_BADBASE64);
/*
* We don't need to test for ctx->val[2] != 64 as
* the bottom two bits of 64 are zero.
*/
if (ctx->val[3] == 64 && (ctx->val[2] & 0x3) != 0)
return (ISC_R_BADBASE64);
n = (ctx->val[2] == 64) ? 1 :
(ctx->val[3] == 64) ? 2 : 3;
if (n != 3) {
ctx->seen_end = ISC_TRUE;
if (ctx->val[2] == 64)
ctx->val[2] = 0;
if (ctx->val[3] == 64)
ctx->val[3] = 0;
}
buf[0] = (ctx->val[0]<<2)|(ctx->val[1]>>4);
buf[1] = (ctx->val[1]<<4)|(ctx->val[2]>>2);
buf[2] = (ctx->val[2]<<6)|(ctx->val[3]);
RETERR(mem_tobuffer(ctx->target, buf, n));
if (ctx->length >= 0) {
if (n > ctx->length)
return (ISC_R_BADBASE64);
else
ctx->length -= n;
}
ctx->digits = 0;
}
return (ISC_R_SUCCESS);
}
static inline isc_result_t
base64_decode_finish(base64_decode_ctx_t *ctx) {
if (ctx->length > 0)
return (ISC_R_UNEXPECTEDEND);
if (ctx->digits != 0)
return (ISC_R_BADBASE64);
return (ISC_R_SUCCESS);
}
isc_result_t
isc_base64_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length) {
base64_decode_ctx_t ctx;
isc_textregion_t *tr;
isc_token_t token;
isc_boolean_t eol;
base64_decode_init(&ctx, length, target);
while (!ctx.seen_end && (ctx.length != 0)) {
unsigned int i;
if (length > 0)
eol = ISC_FALSE;
else
eol = ISC_TRUE;
RETERR(isc_lex_getmastertoken(lexer, &token,
isc_tokentype_string, eol));
if (token.type != isc_tokentype_string)
break;
tr = &token.value.as_textregion;
for (i = 0; i < tr->length; i++)
RETERR(base64_decode_char(&ctx, tr->base[i]));
}
if (ctx.length < 0 && !ctx.seen_end)
isc_lex_ungettoken(lexer, &token);
RETERR(base64_decode_finish(&ctx));
return (ISC_R_SUCCESS);
}
isc_result_t
isc_base64_decodestring(const char *cstr, isc_buffer_t *target) {
base64_decode_ctx_t ctx;
base64_decode_init(&ctx, -1, target);
for (;;) {
int c = *cstr++;
if (c == '\0')
break;
if (c == ' ' || c == '\t' || c == '\n' || c== '\r')
continue;
RETERR(base64_decode_char(&ctx, c));
}
RETERR(base64_decode_finish(&ctx));
return (ISC_R_SUCCESS);
}
static isc_result_t
str_totext(const char *source, isc_buffer_t *target) {
unsigned int l;
isc_region_t region;
isc_buffer_availableregion(target, &region);
l = strlen(source);
if (l > region.length)
return (ISC_R_NOSPACE);
memcpy(region.base, source, l);
isc_buffer_add(target, l);
return (ISC_R_SUCCESS);
}
static isc_result_t
mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) {
isc_region_t tr;
isc_buffer_availableregion(target, &tr);
if (length > tr.length)
return (ISC_R_NOSPACE);
memcpy(tr.base, base, length);
isc_buffer_add(target, length);
return (ISC_R_SUCCESS);
}

View File

@ -1,127 +0,0 @@
/*
* 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: bitstring.c,v 1.17 2007/06/19 23:47:17 tbox Exp $ */
/*! \file */
#include <config.h>
#include <stddef.h>
#include <isc/magic.h>
#include <isc/bitstring.h>
#include <isc/util.h>
#define DIV8(x) ((x) >> 3)
#define MOD8(x) ((x) & 0x00000007U)
#define OCTETS(n) (((n) + 7) >> 3)
#define PADDED(n) ((((n) + 7) >> 3) << 3)
#define BITSET(bs, n) (((bs)->data[DIV8(n)] & \
(1 << (7 - MOD8(n)))) != 0)
#define SETBIT(bs, n) (bs)->data[DIV8(n)] |= (1 << (7 - MOD8(n)))
#define CLEARBIT(bs, n) (bs)->data[DIV8(n)] &= ~(1 << (7 - MOD8(n)))
#define BITSTRING_MAGIC ISC_MAGIC('B', 'S', 't', 'r')
#define VALID_BITSTRING(b) ISC_MAGIC_VALID(b, BITSTRING_MAGIC)
void
isc_bitstring_init(isc_bitstring_t *bitstring, unsigned char *data,
unsigned int length, unsigned int size, isc_boolean_t lsb0)
{
/*
* 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.
*/
REQUIRE(bitstring != NULL);
REQUIRE(data != NULL);
REQUIRE(length <= size);
bitstring->magic = BITSTRING_MAGIC;
bitstring->data = data;
bitstring->length = length;
bitstring->size = size;
bitstring->lsb0 = lsb0;
}
void
isc_bitstring_invalidate(isc_bitstring_t *bitstring) {
/*
* Invalidate 'bitstring'.
*/
REQUIRE(VALID_BITSTRING(bitstring));
bitstring->magic = 0;
bitstring->data = NULL;
bitstring->length = 0;
bitstring->size = 0;
bitstring->lsb0 = ISC_FALSE;
}
void
isc_bitstring_copy(isc_bitstring_t *source, unsigned int sbitpos,
isc_bitstring_t *target, unsigned int tbitpos,
unsigned int n)
{
unsigned int tlast;
/*
* Starting at bit 'sbitpos', copy 'n' bits from 'source' to
* the 'n' bits of 'target' starting at 'tbitpos'.
*/
REQUIRE(VALID_BITSTRING(source));
REQUIRE(VALID_BITSTRING(target));
REQUIRE(source->lsb0 == target->lsb0);
if (source->lsb0) {
REQUIRE(sbitpos <= source->length);
sbitpos = PADDED(source->size) - sbitpos;
REQUIRE(sbitpos >= n);
sbitpos -= n;
} else
REQUIRE(sbitpos + n <= source->length);
tlast = tbitpos + n;
if (target->lsb0) {
REQUIRE(tbitpos <= target->length);
tbitpos = PADDED(target->size) - tbitpos;
REQUIRE(tbitpos >= n);
tbitpos -= n;
} else
REQUIRE(tlast <= target->size);
if (tlast > target->length)
target->length = tlast;
/*
* This is far from optimal...
*/
while (n > 0) {
if (BITSET(source, sbitpos))
SETBIT(target, tbitpos);
else
CLEARBIT(target, tbitpos);
sbitpos++;
tbitpos++;
n--;
}
}

View File

@ -1,64 +0,0 @@
/*
* 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: bufferlist.c,v 1.17 2007/06/19 23:47:17 tbox Exp $ */
/*! \file */
#include <config.h>
#include <stddef.h>
#include <isc/buffer.h>
#include <isc/bufferlist.h>
#include <isc/util.h>
unsigned int
isc_bufferlist_usedcount(isc_bufferlist_t *bl) {
isc_buffer_t *buffer;
unsigned int length;
REQUIRE(bl != NULL);
length = 0;
buffer = ISC_LIST_HEAD(*bl);
while (buffer != NULL) {
REQUIRE(ISC_BUFFER_VALID(buffer));
length += isc_buffer_usedlength(buffer);
buffer = ISC_LIST_NEXT(buffer, link);
}
return (length);
}
unsigned int
isc_bufferlist_availablecount(isc_bufferlist_t *bl) {
isc_buffer_t *buffer;
unsigned int length;
REQUIRE(bl != NULL);
length = 0;
buffer = ISC_LIST_HEAD(*bl);
while (buffer != NULL) {
REQUIRE(ISC_BUFFER_VALID(buffer));
length += isc_buffer_availablelength(buffer);
buffer = ISC_LIST_NEXT(buffer, link);
}
return (length);
}

View File

@ -1,225 +0,0 @@
/*
* Portions Copyright (C) 2004, 2005, 2007, 2008 Internet Systems Consortium, Inc. ("ISC")
* Portions 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.
*/
/*
* Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* $Id: commandline.c,v 1.22 2008/09/25 04:02:39 tbox Exp $ */
/*! \file
* This file was adapted from the NetBSD project's source tree, RCS ID:
* NetBSD: getopt.c,v 1.15 1999/09/20 04:39:37 lukem Exp
*
* The primary change has been to rename items to the ISC namespace
* and format in the ISC coding style.
*/
/*
* \author Principal Authors: Computer Systems Research Group at UC Berkeley
* \author Principal ISC caretaker: DCL
*/
#include <config.h>
#include <stdio.h>
#include <isc/commandline.h>
#include <isc/msgs.h>
#include <isc/string.h>
#include <isc/util.h>
/*% Index into parent argv vector. */
LIBISC_EXTERNAL_DATA int isc_commandline_index = 1;
/*% Character checked for validity. */
LIBISC_EXTERNAL_DATA int isc_commandline_option;
/*% Argument associated with option. */
LIBISC_EXTERNAL_DATA char *isc_commandline_argument;
/*% For printing error messages. */
LIBISC_EXTERNAL_DATA char *isc_commandline_progname;
/*% Print error messages. */
LIBISC_EXTERNAL_DATA isc_boolean_t isc_commandline_errprint = ISC_TRUE;
/*% Reset processing. */
LIBISC_EXTERNAL_DATA isc_boolean_t isc_commandline_reset = ISC_TRUE;
static char endopt = '\0';
#define BADOPT '?'
#define BADARG ':'
#define ENDOPT &endopt
/*!
* getopt --
* Parse argc/argv argument vector.
*/
int
isc_commandline_parse(int argc, char * const *argv, const char *options) {
static char *place = ENDOPT;
char *option; /* Index into *options of option. */
REQUIRE(argc >= 0 && argv != NULL && options != NULL);
/*
* Update scanning pointer, either because a reset was requested or
* the previous argv was finished.
*/
if (isc_commandline_reset || *place == '\0') {
if (isc_commandline_reset) {
isc_commandline_index = 1;
isc_commandline_reset = ISC_FALSE;
}
if (isc_commandline_progname == NULL)
isc_commandline_progname = argv[0];
if (isc_commandline_index >= argc ||
*(place = argv[isc_commandline_index]) != '-') {
/*
* Index out of range or points to non-option.
*/
place = ENDOPT;
return (-1);
}
if (place[1] != '\0' && *++place == '-' && place[1] == '\0') {
/*
* Found '--' to signal end of options. Advance
* index to next argv, the first non-option.
*/
isc_commandline_index++;
place = ENDOPT;
return (-1);
}
}
isc_commandline_option = *place++;
option = strchr(options, isc_commandline_option);
/*
* Ensure valid option has been passed as specified by options string.
* '-:' is never a valid command line option because it could not
* distinguish ':' from the argument specifier in the options string.
*/
if (isc_commandline_option == ':' || option == NULL) {
if (*place == '\0')
isc_commandline_index++;
if (isc_commandline_errprint && *options != ':')
fprintf(stderr, "%s: %s -- %c\n",
isc_commandline_progname,
isc_msgcat_get(isc_msgcat,
ISC_MSGSET_COMMANDLINE,
ISC_MSG_ILLEGALOPT,
"illegal option"),
isc_commandline_option);
return (BADOPT);
}
if (*++option != ':') {
/*
* Option does not take an argument.
*/
isc_commandline_argument = NULL;
/*
* Skip to next argv if at the end of the current argv.
*/
if (*place == '\0')
++isc_commandline_index;
} else {
/*
* Option needs an argument.
*/
if (*place != '\0')
/*
* Option is in this argv, -D1 style.
*/
isc_commandline_argument = place;
else if (argc > ++isc_commandline_index)
/*
* Option is next argv, -D 1 style.
*/
isc_commandline_argument = argv[isc_commandline_index];
else {
/*
* Argument needed, but no more argv.
*/
place = ENDOPT;
/*
* Silent failure with "missing argument" return
* when ':' starts options string, per historical spec.
*/
if (*options == ':')
return (BADARG);
if (isc_commandline_errprint)
fprintf(stderr, "%s: %s -- %c\n",
isc_commandline_progname,
isc_msgcat_get(isc_msgcat,
ISC_MSGSET_COMMANDLINE,
ISC_MSG_OPTNEEDARG,
"option requires "
"an argument"),
isc_commandline_option);
return (BADOPT);
}
place = ENDOPT;
/*
* Point to argv that follows argument.
*/
isc_commandline_index++;
}
return (isc_commandline_option);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,102 +0,0 @@
/*
* 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: fsaccess.c,v 1.10 2007/06/19 23:47:17 tbox Exp $ */
/*! \file
* \brief
* This file contains the OS-independent functionality of the API.
*/
#include <isc/fsaccess.h>
#include <isc/result.h>
#include <isc/util.h>
/*!
* Shorthand. Maybe ISC__FSACCESS_PERMISSIONBITS should not even be in
* <isc/fsaccess.h>. Could check consistency with sizeof(isc_fsaccess_t)
* and the number of bits in each function.
*/
#define STEP (ISC__FSACCESS_PERMISSIONBITS)
#define GROUP (STEP)
#define OTHER (STEP * 2)
void
isc_fsaccess_add(int trustee, int permission, isc_fsaccess_t *access) {
REQUIRE(trustee <= 0x7);
REQUIRE(permission <= 0xFF);
if ((trustee & ISC_FSACCESS_OWNER) != 0)
*access |= permission;
if ((trustee & ISC_FSACCESS_GROUP) != 0)
*access |= (permission << GROUP);
if ((trustee & ISC_FSACCESS_OTHER) != 0)
*access |= (permission << OTHER);
}
void
isc_fsaccess_remove(int trustee, int permission, isc_fsaccess_t *access) {
REQUIRE(trustee <= 0x7);
REQUIRE(permission <= 0xFF);
if ((trustee & ISC_FSACCESS_OWNER) != 0)
*access &= ~permission;
if ((trustee & ISC_FSACCESS_GROUP) != 0)
*access &= ~(permission << GROUP);
if ((trustee & ISC_FSACCESS_OTHER) != 0)
*access &= ~(permission << OTHER);
}
static isc_result_t
check_bad_bits(isc_fsaccess_t access, isc_boolean_t is_dir) {
isc_fsaccess_t bits;
/*
* Check for disallowed user bits.
*/
if (is_dir)
bits = ISC_FSACCESS_READ |
ISC_FSACCESS_WRITE |
ISC_FSACCESS_EXECUTE;
else
bits = ISC_FSACCESS_CREATECHILD |
ISC_FSACCESS_ACCESSCHILD |
ISC_FSACCESS_DELETECHILD |
ISC_FSACCESS_LISTDIRECTORY;
/*
* Set group bad bits.
*/
bits |= bits << STEP;
/*
* Set other bad bits.
*/
bits |= bits << STEP;
if ((access & bits) != 0) {
if (is_dir)
return (ISC_R_NOTFILE);
else
return (ISC_R_NOTDIRECTORY);
}
return (ISC_R_SUCCESS);
}

View File

@ -1,404 +0,0 @@
/*
* 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.c,v 1.16 2009/09/01 00:22:28 jinmei Exp $ */
/*! \file
* Some portion of this code was derived from universal hash function
* libraries of Rice University.
\section license UH Universal Hashing Library
Copyright ((c)) 2002, Rice University
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of Rice University (RICE) 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 RICE and the contributors on an "as is"
basis, without any representations or warranties of any kind, express
or implied including, but not limited to, representations or
warranties of non-infringement, merchantability or fitness for a
particular purpose. In no event shall RICE 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.
*/
#include <config.h>
#include <isc/entropy.h>
#include <isc/hash.h>
#include <isc/mem.h>
#include <isc/magic.h>
#include <isc/mutex.h>
#include <isc/once.h>
#include <isc/random.h>
#include <isc/refcount.h>
#include <isc/string.h>
#include <isc/util.h>
#define HASH_MAGIC ISC_MAGIC('H', 'a', 's', 'h')
#define VALID_HASH(h) ISC_MAGIC_VALID((h), HASH_MAGIC)
/*%
* A large 32-bit prime number that specifies the range of the hash output.
*/
#define PRIME32 0xFFFFFFFB /* 2^32 - 5 */
/*@{*/
/*%
* Types of random seed and hash accumulator. Perhaps they can be system
* dependent.
*/
typedef isc_uint32_t hash_accum_t;
typedef isc_uint16_t hash_random_t;
/*@}*/
/*% isc hash structure */
struct isc_hash {
unsigned int magic;
isc_mem_t *mctx;
isc_mutex_t lock;
isc_boolean_t initialized;
isc_refcount_t refcnt;
isc_entropy_t *entropy; /*%< entropy source */
unsigned int limit; /*%< upper limit of key length */
size_t vectorlen; /*%< size of the vector below */
hash_random_t *rndvector; /*%< random vector for universal hashing */
};
static isc_mutex_t createlock;
static isc_once_t once = ISC_ONCE_INIT;
static isc_hash_t *hash = NULL;
static unsigned char maptolower[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
};
isc_result_t
isc_hash_ctxcreate(isc_mem_t *mctx, isc_entropy_t *entropy,
unsigned int limit, isc_hash_t **hctxp)
{
isc_result_t result;
isc_hash_t *hctx;
size_t vlen;
hash_random_t *rv;
hash_accum_t overflow_limit;
REQUIRE(mctx != NULL);
REQUIRE(hctxp != NULL && *hctxp == NULL);
/*
* Overflow check. Since our implementation only does a modulo
* operation at the last stage of hash calculation, the accumulator
* must not overflow.
*/
overflow_limit =
1 << (((sizeof(hash_accum_t) - sizeof(hash_random_t))) * 8);
if (overflow_limit < (limit + 1) * 0xff)
return (ISC_R_RANGE);
hctx = isc_mem_get(mctx, sizeof(isc_hash_t));
if (hctx == NULL)
return (ISC_R_NOMEMORY);
vlen = sizeof(hash_random_t) * (limit + 1);
rv = isc_mem_get(mctx, vlen);
if (rv == NULL) {
result = ISC_R_NOMEMORY;
goto errout;
}
/*
* We need a lock.
*/
result = isc_mutex_init(&hctx->lock);
if (result != ISC_R_SUCCESS)
goto errout;
/*
* From here down, no failures will/can occur.
*/
hctx->magic = HASH_MAGIC;
hctx->mctx = NULL;
isc_mem_attach(mctx, &hctx->mctx);
hctx->initialized = ISC_FALSE;
result = isc_refcount_init(&hctx->refcnt, 1);
if (result != ISC_R_SUCCESS)
goto cleanup_lock;
hctx->entropy = NULL;
hctx->limit = limit;
hctx->vectorlen = vlen;
hctx->rndvector = rv;
#ifdef BIND9
if (entropy != NULL)
isc_entropy_attach(entropy, &hctx->entropy);
#else
UNUSED(entropy);
#endif
*hctxp = hctx;
return (ISC_R_SUCCESS);
cleanup_lock:
DESTROYLOCK(&hctx->lock);
errout:
isc_mem_put(mctx, hctx, sizeof(isc_hash_t));
if (rv != NULL)
isc_mem_put(mctx, rv, vlen);
return (result);
}
static void
initialize_lock(void) {
RUNTIME_CHECK(isc_mutex_init(&createlock) == ISC_R_SUCCESS);
}
isc_result_t
isc_hash_create(isc_mem_t *mctx, isc_entropy_t *entropy, size_t limit) {
isc_result_t result = ISC_R_SUCCESS;
REQUIRE(mctx != NULL);
INSIST(hash == NULL);
RUNTIME_CHECK(isc_once_do(&once, initialize_lock) == ISC_R_SUCCESS);
LOCK(&createlock);
if (hash == NULL)
result = isc_hash_ctxcreate(mctx, entropy, limit, &hash);
UNLOCK(&createlock);
return (result);
}
void
isc_hash_ctxinit(isc_hash_t *hctx) {
LOCK(&hctx->lock);
if (hctx->initialized == ISC_TRUE)
goto out;
if (hctx->entropy) {
#ifdef BIND9
isc_result_t result;
result = isc_entropy_getdata(hctx->entropy,
hctx->rndvector, hctx->vectorlen,
NULL, 0);
INSIST(result == ISC_R_SUCCESS);
#else
INSIST(0);
#endif
} else {
isc_uint32_t pr;
unsigned int i, copylen;
unsigned char *p;
p = (unsigned char *)hctx->rndvector;
for (i = 0; i < hctx->vectorlen; i += copylen, p += copylen) {
isc_random_get(&pr);
if (i + sizeof(pr) <= hctx->vectorlen)
copylen = sizeof(pr);
else
copylen = hctx->vectorlen - i;
memcpy(p, &pr, copylen);
}
INSIST(p == (unsigned char *)hctx->rndvector +
hctx->vectorlen);
}
hctx->initialized = ISC_TRUE;
out:
UNLOCK(&hctx->lock);
}
void
isc_hash_init() {
INSIST(hash != NULL && VALID_HASH(hash));
isc_hash_ctxinit(hash);
}
void
isc_hash_ctxattach(isc_hash_t *hctx, isc_hash_t **hctxp) {
REQUIRE(VALID_HASH(hctx));
REQUIRE(hctxp != NULL && *hctxp == NULL);
isc_refcount_increment(&hctx->refcnt, NULL);
*hctxp = hctx;
}
static void
destroy(isc_hash_t **hctxp) {
isc_hash_t *hctx;
isc_mem_t *mctx;
unsigned char canary0[4], canary1[4];
REQUIRE(hctxp != NULL && *hctxp != NULL);
hctx = *hctxp;
*hctxp = NULL;
LOCK(&hctx->lock);
isc_refcount_destroy(&hctx->refcnt);
mctx = hctx->mctx;
#ifdef BIND9
if (hctx->entropy != NULL)
isc_entropy_detach(&hctx->entropy);
#endif
if (hctx->rndvector != NULL)
isc_mem_put(mctx, hctx->rndvector, hctx->vectorlen);
UNLOCK(&hctx->lock);
DESTROYLOCK(&hctx->lock);
memcpy(canary0, hctx + 1, sizeof(canary0));
memset(hctx, 0, sizeof(isc_hash_t));
memcpy(canary1, hctx + 1, sizeof(canary1));
INSIST(memcmp(canary0, canary1, sizeof(canary0)) == 0);
isc_mem_put(mctx, hctx, sizeof(isc_hash_t));
isc_mem_detach(&mctx);
}
void
isc_hash_ctxdetach(isc_hash_t **hctxp) {
isc_hash_t *hctx;
unsigned int refs;
REQUIRE(hctxp != NULL && VALID_HASH(*hctxp));
hctx = *hctxp;
isc_refcount_decrement(&hctx->refcnt, &refs);
if (refs == 0)
destroy(&hctx);
*hctxp = NULL;
}
void
isc_hash_destroy() {
unsigned int refs;
INSIST(hash != NULL && VALID_HASH(hash));
isc_refcount_decrement(&hash->refcnt, &refs);
INSIST(refs == 0);
destroy(&hash);
}
static inline unsigned int
hash_calc(isc_hash_t *hctx, const unsigned char *key, unsigned int keylen,
isc_boolean_t case_sensitive)
{
hash_accum_t partial_sum = 0;
hash_random_t *p = hctx->rndvector;
unsigned int i = 0;
/* Make it sure that the hash context is initialized. */
if (hctx->initialized == ISC_FALSE)
isc_hash_ctxinit(hctx);
if (case_sensitive) {
for (i = 0; i < keylen; i++)
partial_sum += key[i] * (hash_accum_t)p[i];
} else {
for (i = 0; i < keylen; i++)
partial_sum += maptolower[key[i]] * (hash_accum_t)p[i];
}
partial_sum += p[i];
return ((unsigned int)(partial_sum % PRIME32));
}
unsigned int
isc_hash_ctxcalc(isc_hash_t *hctx, const unsigned char *key,
unsigned int keylen, isc_boolean_t case_sensitive)
{
REQUIRE(hctx != NULL && VALID_HASH(hctx));
REQUIRE(keylen <= hctx->limit);
return (hash_calc(hctx, key, keylen, case_sensitive));
}
unsigned int
isc_hash_calc(const unsigned char *key, unsigned int keylen,
isc_boolean_t case_sensitive)
{
INSIST(hash != NULL && VALID_HASH(hash));
REQUIRE(keylen <= hash->limit);
return (hash_calc(hash, key, keylen, case_sensitive));
}

View File

@ -1,265 +0,0 @@
/*
* Copyright (C) 2004-2007, 2010-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$ */
/*! \file
* Heap implementation of priority queues adapted from the following:
*
* \li "Introduction to Algorithms," Cormen, Leiserson, and Rivest,
* MIT Press / McGraw Hill, 1990, ISBN 0-262-03141-8, chapter 7.
*
* \li "Algorithms," Second Edition, Sedgewick, Addison-Wesley, 1988,
* ISBN 0-201-06673-4, chapter 11.
*/
#include <config.h>
#include <isc/heap.h>
#include <isc/magic.h>
#include <isc/mem.h>
#include <isc/string.h> /* Required for memcpy. */
#include <isc/util.h>
/*@{*/
/*%
* Note: to make heap_parent and heap_left easy to compute, the first
* element of the heap array is not used; i.e. heap subscripts are 1-based,
* not 0-based. The parent is index/2, and the left-child is index*2.
* The right child is index*2+1.
*/
#define heap_parent(i) ((i) >> 1)
#define heap_left(i) ((i) << 1)
/*@}*/
#define SIZE_INCREMENT 1024
#define HEAP_MAGIC ISC_MAGIC('H', 'E', 'A', 'P')
#define VALID_HEAP(h) ISC_MAGIC_VALID(h, HEAP_MAGIC)
/*%
* When the heap is in a consistent state, the following invariant
* holds true: for every element i > 1, heap_parent(i) has a priority
* higher than or equal to that of i.
*/
#define HEAPCONDITION(i) ((i) == 1 || \
! heap->compare(heap->array[(i)], \
heap->array[heap_parent(i)]))
/*% ISC heap structure. */
struct isc_heap {
unsigned int magic;
isc_mem_t * mctx;
unsigned int size;
unsigned int size_increment;
unsigned int last;
void **array;
isc_heapcompare_t compare;
isc_heapindex_t index;
};
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)
{
isc_heap_t *heap;
REQUIRE(heapp != NULL && *heapp == NULL);
REQUIRE(compare != NULL);
heap = isc_mem_get(mctx, sizeof(*heap));
if (heap == NULL)
return (ISC_R_NOMEMORY);
heap->magic = HEAP_MAGIC;
heap->size = 0;
heap->mctx = NULL;
isc_mem_attach(mctx, &heap->mctx);
if (size_increment == 0)
heap->size_increment = SIZE_INCREMENT;
else
heap->size_increment = size_increment;
heap->last = 0;
heap->array = NULL;
heap->compare = compare;
heap->index = index;
*heapp = heap;
return (ISC_R_SUCCESS);
}
void
isc_heap_destroy(isc_heap_t **heapp) {
isc_heap_t *heap;
REQUIRE(heapp != NULL);
heap = *heapp;
REQUIRE(VALID_HEAP(heap));
if (heap->array != NULL)
isc_mem_put(heap->mctx, heap->array,
heap->size * sizeof(void *));
heap->magic = 0;
isc_mem_putanddetach(&heap->mctx, heap, sizeof(*heap));
*heapp = NULL;
}
static isc_boolean_t
resize(isc_heap_t *heap) {
void **new_array;
size_t new_size;
REQUIRE(VALID_HEAP(heap));
new_size = heap->size + heap->size_increment;
new_array = isc_mem_get(heap->mctx, new_size * sizeof(void *));
if (new_array == NULL)
return (ISC_FALSE);
if (heap->array != NULL) {
memcpy(new_array, heap->array, heap->size * sizeof(void *));
isc_mem_put(heap->mctx, heap->array,
heap->size * sizeof(void *));
}
heap->size = new_size;
heap->array = new_array;
return (ISC_TRUE);
}
static void
float_up(isc_heap_t *heap, unsigned int i, void *elt) {
unsigned int p;
for (p = heap_parent(i) ;
i > 1 && heap->compare(elt, heap->array[p]) ;
i = p, p = heap_parent(i)) {
heap->array[i] = heap->array[p];
if (heap->index != NULL)
(heap->index)(heap->array[i], i);
}
heap->array[i] = elt;
if (heap->index != NULL)
(heap->index)(heap->array[i], i);
INSIST(HEAPCONDITION(i));
}
static void
sink_down(isc_heap_t *heap, unsigned int i, void *elt) {
unsigned int j, size, half_size;
size = heap->last;
half_size = size / 2;
while (i <= half_size) {
/* Find the smallest of the (at most) two children. */
j = heap_left(i);
if (j < size && heap->compare(heap->array[j+1],
heap->array[j]))
j++;
if (heap->compare(elt, heap->array[j]))
break;
heap->array[i] = heap->array[j];
if (heap->index != NULL)
(heap->index)(heap->array[i], i);
i = j;
}
heap->array[i] = elt;
if (heap->index != NULL)
(heap->index)(heap->array[i], i);
INSIST(HEAPCONDITION(i));
}
isc_result_t
isc_heap_insert(isc_heap_t *heap, void *elt) {
unsigned int new_last;
REQUIRE(VALID_HEAP(heap));
new_last = heap->last + 1;
RUNTIME_CHECK(new_last > 0); /* overflow check */
if (new_last >= heap->size && !resize(heap))
return (ISC_R_NOMEMORY);
heap->last = new_last;
float_up(heap, new_last, elt);
return (ISC_R_SUCCESS);
}
void
isc_heap_delete(isc_heap_t *heap, unsigned int index) {
void *elt;
isc_boolean_t less;
REQUIRE(VALID_HEAP(heap));
REQUIRE(index >= 1 && index <= heap->last);
if (index == heap->last) {
heap->array[heap->last] = NULL;
heap->last--;
} else {
elt = heap->array[heap->last];
heap->array[heap->last] = NULL;
heap->last--;
less = heap->compare(elt, heap->array[index]);
heap->array[index] = elt;
if (less)
float_up(heap, index, heap->array[index]);
else
sink_down(heap, index, heap->array[index]);
}
}
void
isc_heap_increased(isc_heap_t *heap, unsigned int index) {
REQUIRE(VALID_HEAP(heap));
REQUIRE(index >= 1 && index <= heap->last);
float_up(heap, index, heap->array[index]);
}
void
isc_heap_decreased(isc_heap_t *heap, unsigned int index) {
REQUIRE(VALID_HEAP(heap));
REQUIRE(index >= 1 && index <= heap->last);
sink_down(heap, index, heap->array[index]);
}
void *
isc_heap_element(isc_heap_t *heap, unsigned int index) {
REQUIRE(VALID_HEAP(heap));
REQUIRE(index >= 1);
if (index <= heap->last)
return (heap->array[index]);
return (NULL);
}
void
isc_heap_foreach(isc_heap_t *heap, isc_heapaction_t action, void *uap) {
unsigned int i;
REQUIRE(VALID_HEAP(heap));
REQUIRE(action != NULL);
for (i = 1 ; i <= heap->last ; i++)
(action)(heap->array[i], uap);
}

View File

@ -1,201 +0,0 @@
/*
* Copyright (C) 2004, 2005, 2007, 2008 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: hex.c,v 1.20 2008/09/25 04:02:39 tbox Exp $ */
/*! \file */
#include <config.h>
#include <ctype.h>
#include <isc/buffer.h>
#include <isc/hex.h>
#include <isc/lex.h>
#include <isc/string.h>
#include <isc/util.h>
#define RETERR(x) do { \
isc_result_t _r = (x); \
if (_r != ISC_R_SUCCESS) \
return (_r); \
} while (0)
/*
* BEW: These static functions are copied from lib/dns/rdata.c.
*/
static isc_result_t
str_totext(const char *source, isc_buffer_t *target);
static isc_result_t
mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length);
static const char hex[] = "0123456789ABCDEF";
isc_result_t
isc_hex_totext(isc_region_t *source, int wordlength,
const char *wordbreak, isc_buffer_t *target)
{
char buf[3];
unsigned int loops = 0;
if (wordlength < 2)
wordlength = 2;
memset(buf, 0, sizeof(buf));
while (source->length > 0) {
buf[0] = hex[(source->base[0] >> 4) & 0xf];
buf[1] = hex[(source->base[0]) & 0xf];
RETERR(str_totext(buf, target));
isc_region_consume(source, 1);
loops++;
if (source->length != 0 &&
(int)((loops + 1) * 2) >= wordlength)
{
loops = 0;
RETERR(str_totext(wordbreak, target));
}
}
return (ISC_R_SUCCESS);
}
/*%
* State of a hex decoding process in progress.
*/
typedef struct {
int length; /*%< Desired length of binary data or -1 */
isc_buffer_t *target; /*%< Buffer for resulting binary data */
int digits; /*%< Number of buffered hex digits */
int val[2];
} hex_decode_ctx_t;
static inline void
hex_decode_init(hex_decode_ctx_t *ctx, int length, isc_buffer_t *target)
{
ctx->digits = 0;
ctx->length = length;
ctx->target = target;
}
static inline isc_result_t
hex_decode_char(hex_decode_ctx_t *ctx, int c) {
char *s;
if ((s = strchr(hex, toupper(c))) == NULL)
return (ISC_R_BADHEX);
ctx->val[ctx->digits++] = s - hex;
if (ctx->digits == 2) {
unsigned char num;
num = (ctx->val[0] << 4) + (ctx->val[1]);
RETERR(mem_tobuffer(ctx->target, &num, 1));
if (ctx->length >= 0) {
if (ctx->length == 0)
return (ISC_R_BADHEX);
else
ctx->length -= 1;
}
ctx->digits = 0;
}
return (ISC_R_SUCCESS);
}
static inline isc_result_t
hex_decode_finish(hex_decode_ctx_t *ctx) {
if (ctx->length > 0)
return (ISC_R_UNEXPECTEDEND);
if (ctx->digits != 0)
return (ISC_R_BADHEX);
return (ISC_R_SUCCESS);
}
isc_result_t
isc_hex_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length) {
hex_decode_ctx_t ctx;
isc_textregion_t *tr;
isc_token_t token;
isc_boolean_t eol;
hex_decode_init(&ctx, length, target);
while (ctx.length != 0) {
unsigned int i;
if (length > 0)
eol = ISC_FALSE;
else
eol = ISC_TRUE;
RETERR(isc_lex_getmastertoken(lexer, &token,
isc_tokentype_string, eol));
if (token.type != isc_tokentype_string)
break;
tr = &token.value.as_textregion;
for (i = 0; i < tr->length; i++)
RETERR(hex_decode_char(&ctx, tr->base[i]));
}
if (ctx.length < 0)
isc_lex_ungettoken(lexer, &token);
RETERR(hex_decode_finish(&ctx));
return (ISC_R_SUCCESS);
}
isc_result_t
isc_hex_decodestring(const char *cstr, isc_buffer_t *target) {
hex_decode_ctx_t ctx;
hex_decode_init(&ctx, -1, target);
for (;;) {
int c = *cstr++;
if (c == '\0')
break;
if (c == ' ' || c == '\t' || c == '\n' || c== '\r')
continue;
RETERR(hex_decode_char(&ctx, c));
}
RETERR(hex_decode_finish(&ctx));
return (ISC_R_SUCCESS);
}
static isc_result_t
str_totext(const char *source, isc_buffer_t *target) {
unsigned int l;
isc_region_t region;
isc_buffer_availableregion(target, &region);
l = strlen(source);
if (l > region.length)
return (ISC_R_NOSPACE);
memcpy(region.base, source, l);
isc_buffer_add(target, l);
return (ISC_R_SUCCESS);
}
static isc_result_t
mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) {
isc_region_t tr;
isc_buffer_availableregion(target, &tr);
if (length > tr.length)
return (ISC_R_NOSPACE);
memcpy(tr.base, base, length);
isc_buffer_add(target, length);
return (ISC_R_SUCCESS);
}

View File

@ -1,149 +0,0 @@
/*
* 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.c,v 1.16 2009/02/06 23:47:42 tbox Exp $ */
/*! \file
* This code implements the HMAC-MD5 keyed hash algorithm
* described in RFC2104.
*/
#include "config.h"
#include <isc/assertions.h>
#include <isc/hmacmd5.h>
#include <isc/md5.h>
#include <isc/platform.h>
#include <isc/string.h>
#include <isc/types.h>
#include <isc/util.h>
#ifdef ISC_PLATFORM_OPENSSLHASH
void
isc_hmacmd5_init(isc_hmacmd5_t *ctx, const unsigned char *key,
unsigned int len)
{
HMAC_Init(ctx, (const void *) key, (int) len, EVP_md5());
}
void
isc_hmacmd5_invalidate(isc_hmacmd5_t *ctx) {
HMAC_CTX_cleanup(ctx);
}
void
isc_hmacmd5_update(isc_hmacmd5_t *ctx, const unsigned char *buf,
unsigned int len)
{
HMAC_Update(ctx, buf, (int) len);
}
void
isc_hmacmd5_sign(isc_hmacmd5_t *ctx, unsigned char *digest) {
HMAC_Final(ctx, digest, NULL);
HMAC_CTX_cleanup(ctx);
}
#else
#define PADLEN 64
#define IPAD 0x36
#define OPAD 0x5C
/*!
* Start HMAC-MD5 process. Initialize an md5 context and digest the key.
*/
void
isc_hmacmd5_init(isc_hmacmd5_t *ctx, const unsigned char *key,
unsigned int len)
{
unsigned char ipad[PADLEN];
int i;
memset(ctx->key, 0, sizeof(ctx->key));
if (len > sizeof(ctx->key)) {
isc_md5_t md5ctx;
isc_md5_init(&md5ctx);
isc_md5_update(&md5ctx, key, len);
isc_md5_final(&md5ctx, ctx->key);
} else
memcpy(ctx->key, key, len);
isc_md5_init(&ctx->md5ctx);
memset(ipad, IPAD, sizeof(ipad));
for (i = 0; i < PADLEN; i++)
ipad[i] ^= ctx->key[i];
isc_md5_update(&ctx->md5ctx, ipad, sizeof(ipad));
}
void
isc_hmacmd5_invalidate(isc_hmacmd5_t *ctx) {
isc_md5_invalidate(&ctx->md5ctx);
memset(ctx->key, 0, sizeof(ctx->key));
}
/*!
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void
isc_hmacmd5_update(isc_hmacmd5_t *ctx, const unsigned char *buf,
unsigned int len)
{
isc_md5_update(&ctx->md5ctx, buf, len);
}
/*!
* Compute signature - finalize MD5 operation and reapply MD5.
*/
void
isc_hmacmd5_sign(isc_hmacmd5_t *ctx, unsigned char *digest) {
unsigned char opad[PADLEN];
int i;
isc_md5_final(&ctx->md5ctx, digest);
memset(opad, OPAD, sizeof(opad));
for (i = 0; i < PADLEN; i++)
opad[i] ^= ctx->key[i];
isc_md5_init(&ctx->md5ctx);
isc_md5_update(&ctx->md5ctx, opad, sizeof(opad));
isc_md5_update(&ctx->md5ctx, digest, ISC_MD5_DIGESTLENGTH);
isc_md5_final(&ctx->md5ctx, digest);
isc_hmacmd5_invalidate(ctx);
}
#endif /* !ISC_PLATFORM_OPENSSLHASH */
/*!
* Verify signature - finalize MD5 operation and reapply MD5, then
* compare to the supplied digest.
*/
isc_boolean_t
isc_hmacmd5_verify(isc_hmacmd5_t *ctx, unsigned char *digest) {
return (isc_hmacmd5_verify2(ctx, digest, ISC_MD5_DIGESTLENGTH));
}
isc_boolean_t
isc_hmacmd5_verify2(isc_hmacmd5_t *ctx, unsigned char *digest, size_t len) {
unsigned char newdigest[ISC_MD5_DIGESTLENGTH];
REQUIRE(len <= ISC_MD5_DIGESTLENGTH);
isc_hmacmd5_sign(ctx, newdigest);
return (ISC_TF(isc_tsmemcmp(digest, newdigest, len) == 0));
}

View File

@ -1,594 +0,0 @@
/*
* Copyright (C) 2005-2007, 2009, 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$ */
/*
* This code implements the HMAC-SHA1, HMAC-SHA224, HMAC-SHA256, HMAC-SHA384
* and HMAC-SHA512 keyed hash algorithm described in RFC 2104 and
* draft-ietf-dnsext-tsig-sha-01.txt.
*/
#include "config.h"
#include <isc/assertions.h>
#include <isc/hmacsha.h>
#include <isc/platform.h>
#include <isc/sha1.h>
#include <isc/sha2.h>
#include <isc/string.h>
#include <isc/types.h>
#include <isc/util.h>
#ifdef ISC_PLATFORM_OPENSSLHASH
void
isc_hmacsha1_init(isc_hmacsha1_t *ctx, const unsigned char *key,
unsigned int len)
{
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha1());
}
void
isc_hmacsha1_invalidate(isc_hmacsha1_t *ctx) {
HMAC_CTX_cleanup(ctx);
}
void
isc_hmacsha1_update(isc_hmacsha1_t *ctx, const unsigned char *buf,
unsigned int len)
{
HMAC_Update(ctx, buf, (int) len);
}
void
isc_hmacsha1_sign(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len) {
unsigned char newdigest[ISC_SHA1_DIGESTLENGTH];
REQUIRE(len <= ISC_SHA1_DIGESTLENGTH);
HMAC_Final(ctx, newdigest, NULL);
HMAC_CTX_cleanup(ctx);
memcpy(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
}
void
isc_hmacsha224_init(isc_hmacsha224_t *ctx, const unsigned char *key,
unsigned int len)
{
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha224());
}
void
isc_hmacsha224_invalidate(isc_hmacsha224_t *ctx) {
HMAC_CTX_cleanup(ctx);
}
void
isc_hmacsha224_update(isc_hmacsha224_t *ctx, const unsigned char *buf,
unsigned int len)
{
HMAC_Update(ctx, buf, (int) len);
}
void
isc_hmacsha224_sign(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len) {
unsigned char newdigest[ISC_SHA224_DIGESTLENGTH];
REQUIRE(len <= ISC_SHA224_DIGESTLENGTH);
HMAC_Final(ctx, newdigest, NULL);
HMAC_CTX_cleanup(ctx);
memcpy(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
}
void
isc_hmacsha256_init(isc_hmacsha256_t *ctx, const unsigned char *key,
unsigned int len)
{
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha256());
}
void
isc_hmacsha256_invalidate(isc_hmacsha256_t *ctx) {
HMAC_CTX_cleanup(ctx);
}
void
isc_hmacsha256_update(isc_hmacsha256_t *ctx, const unsigned char *buf,
unsigned int len)
{
HMAC_Update(ctx, buf, (int) len);
}
void
isc_hmacsha256_sign(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len) {
unsigned char newdigest[ISC_SHA256_DIGESTLENGTH];
REQUIRE(len <= ISC_SHA256_DIGESTLENGTH);
HMAC_Final(ctx, newdigest, NULL);
HMAC_CTX_cleanup(ctx);
memcpy(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
}
void
isc_hmacsha384_init(isc_hmacsha384_t *ctx, const unsigned char *key,
unsigned int len)
{
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha384());
}
void
isc_hmacsha384_invalidate(isc_hmacsha384_t *ctx) {
HMAC_CTX_cleanup(ctx);
}
void
isc_hmacsha384_update(isc_hmacsha384_t *ctx, const unsigned char *buf,
unsigned int len)
{
HMAC_Update(ctx, buf, (int) len);
}
void
isc_hmacsha384_sign(isc_hmacsha384_t *ctx, unsigned char *digest, size_t len) {
unsigned char newdigest[ISC_SHA384_DIGESTLENGTH];
REQUIRE(len <= ISC_SHA384_DIGESTLENGTH);
HMAC_Final(ctx, newdigest, NULL);
HMAC_CTX_cleanup(ctx);
memcpy(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
}
void
isc_hmacsha512_init(isc_hmacsha512_t *ctx, const unsigned char *key,
unsigned int len)
{
HMAC_Init(ctx, (const void *) key, (int) len, EVP_sha512());
}
void
isc_hmacsha512_invalidate(isc_hmacsha512_t *ctx) {
HMAC_CTX_cleanup(ctx);
}
void
isc_hmacsha512_update(isc_hmacsha512_t *ctx, const unsigned char *buf,
unsigned int len)
{
HMAC_Update(ctx, buf, (int) len);
}
void
isc_hmacsha512_sign(isc_hmacsha512_t *ctx, unsigned char *digest, size_t len) {
unsigned char newdigest[ISC_SHA512_DIGESTLENGTH];
REQUIRE(len <= ISC_SHA512_DIGESTLENGTH);
HMAC_Final(ctx, newdigest, NULL);
HMAC_CTX_cleanup(ctx);
memcpy(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
}
#else
#define IPAD 0x36
#define OPAD 0x5C
/*
* Start HMAC-SHA1 process. Initialize an sha1 context and digest the key.
*/
void
isc_hmacsha1_init(isc_hmacsha1_t *ctx, const unsigned char *key,
unsigned int len)
{
unsigned char ipad[ISC_SHA1_BLOCK_LENGTH];
unsigned int i;
memset(ctx->key, 0, sizeof(ctx->key));
if (len > sizeof(ctx->key)) {
isc_sha1_t sha1ctx;
isc_sha1_init(&sha1ctx);
isc_sha1_update(&sha1ctx, key, len);
isc_sha1_final(&sha1ctx, ctx->key);
} else
memcpy(ctx->key, key, len);
isc_sha1_init(&ctx->sha1ctx);
memset(ipad, IPAD, sizeof(ipad));
for (i = 0; i < ISC_SHA1_BLOCK_LENGTH; i++)
ipad[i] ^= ctx->key[i];
isc_sha1_update(&ctx->sha1ctx, ipad, sizeof(ipad));
}
void
isc_hmacsha1_invalidate(isc_hmacsha1_t *ctx) {
isc_sha1_invalidate(&ctx->sha1ctx);
memset(ctx, 0, sizeof(*ctx));
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void
isc_hmacsha1_update(isc_hmacsha1_t *ctx, const unsigned char *buf,
unsigned int len)
{
isc_sha1_update(&ctx->sha1ctx, buf, len);
}
/*
* Compute signature - finalize SHA1 operation and reapply SHA1.
*/
void
isc_hmacsha1_sign(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len) {
unsigned char opad[ISC_SHA1_BLOCK_LENGTH];
unsigned char newdigest[ISC_SHA1_DIGESTLENGTH];
unsigned int i;
REQUIRE(len <= ISC_SHA1_DIGESTLENGTH);
isc_sha1_final(&ctx->sha1ctx, newdigest);
memset(opad, OPAD, sizeof(opad));
for (i = 0; i < ISC_SHA1_BLOCK_LENGTH; i++)
opad[i] ^= ctx->key[i];
isc_sha1_init(&ctx->sha1ctx);
isc_sha1_update(&ctx->sha1ctx, opad, sizeof(opad));
isc_sha1_update(&ctx->sha1ctx, newdigest, ISC_SHA1_DIGESTLENGTH);
isc_sha1_final(&ctx->sha1ctx, newdigest);
isc_hmacsha1_invalidate(ctx);
memcpy(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
}
/*
* Start HMAC-SHA224 process. Initialize an sha224 context and digest the key.
*/
void
isc_hmacsha224_init(isc_hmacsha224_t *ctx, const unsigned char *key,
unsigned int len)
{
unsigned char ipad[ISC_SHA224_BLOCK_LENGTH];
unsigned int i;
memset(ctx->key, 0, sizeof(ctx->key));
if (len > sizeof(ctx->key)) {
isc_sha224_t sha224ctx;
isc_sha224_init(&sha224ctx);
isc_sha224_update(&sha224ctx, key, len);
isc_sha224_final(ctx->key, &sha224ctx);
} else
memcpy(ctx->key, key, len);
isc_sha224_init(&ctx->sha224ctx);
memset(ipad, IPAD, sizeof(ipad));
for (i = 0; i < ISC_SHA224_BLOCK_LENGTH; i++)
ipad[i] ^= ctx->key[i];
isc_sha224_update(&ctx->sha224ctx, ipad, sizeof(ipad));
}
void
isc_hmacsha224_invalidate(isc_hmacsha224_t *ctx) {
memset(ctx, 0, sizeof(*ctx));
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void
isc_hmacsha224_update(isc_hmacsha224_t *ctx, const unsigned char *buf,
unsigned int len)
{
isc_sha224_update(&ctx->sha224ctx, buf, len);
}
/*
* Compute signature - finalize SHA224 operation and reapply SHA224.
*/
void
isc_hmacsha224_sign(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len) {
unsigned char opad[ISC_SHA224_BLOCK_LENGTH];
unsigned char newdigest[ISC_SHA224_DIGESTLENGTH];
unsigned int i;
REQUIRE(len <= ISC_SHA224_DIGESTLENGTH);
isc_sha224_final(newdigest, &ctx->sha224ctx);
memset(opad, OPAD, sizeof(opad));
for (i = 0; i < ISC_SHA224_BLOCK_LENGTH; i++)
opad[i] ^= ctx->key[i];
isc_sha224_init(&ctx->sha224ctx);
isc_sha224_update(&ctx->sha224ctx, opad, sizeof(opad));
isc_sha224_update(&ctx->sha224ctx, newdigest, ISC_SHA224_DIGESTLENGTH);
isc_sha224_final(newdigest, &ctx->sha224ctx);
memcpy(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
}
/*
* Start HMAC-SHA256 process. Initialize an sha256 context and digest the key.
*/
void
isc_hmacsha256_init(isc_hmacsha256_t *ctx, const unsigned char *key,
unsigned int len)
{
unsigned char ipad[ISC_SHA256_BLOCK_LENGTH];
unsigned int i;
memset(ctx->key, 0, sizeof(ctx->key));
if (len > sizeof(ctx->key)) {
isc_sha256_t sha256ctx;
isc_sha256_init(&sha256ctx);
isc_sha256_update(&sha256ctx, key, len);
isc_sha256_final(ctx->key, &sha256ctx);
} else
memcpy(ctx->key, key, len);
isc_sha256_init(&ctx->sha256ctx);
memset(ipad, IPAD, sizeof(ipad));
for (i = 0; i < ISC_SHA256_BLOCK_LENGTH; i++)
ipad[i] ^= ctx->key[i];
isc_sha256_update(&ctx->sha256ctx, ipad, sizeof(ipad));
}
void
isc_hmacsha256_invalidate(isc_hmacsha256_t *ctx) {
memset(ctx, 0, sizeof(*ctx));
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void
isc_hmacsha256_update(isc_hmacsha256_t *ctx, const unsigned char *buf,
unsigned int len)
{
isc_sha256_update(&ctx->sha256ctx, buf, len);
}
/*
* Compute signature - finalize SHA256 operation and reapply SHA256.
*/
void
isc_hmacsha256_sign(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len) {
unsigned char opad[ISC_SHA256_BLOCK_LENGTH];
unsigned char newdigest[ISC_SHA256_DIGESTLENGTH];
unsigned int i;
REQUIRE(len <= ISC_SHA256_DIGESTLENGTH);
isc_sha256_final(newdigest, &ctx->sha256ctx);
memset(opad, OPAD, sizeof(opad));
for (i = 0; i < ISC_SHA256_BLOCK_LENGTH; i++)
opad[i] ^= ctx->key[i];
isc_sha256_init(&ctx->sha256ctx);
isc_sha256_update(&ctx->sha256ctx, opad, sizeof(opad));
isc_sha256_update(&ctx->sha256ctx, newdigest, ISC_SHA256_DIGESTLENGTH);
isc_sha256_final(newdigest, &ctx->sha256ctx);
memcpy(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
}
/*
* Start HMAC-SHA384 process. Initialize an sha384 context and digest the key.
*/
void
isc_hmacsha384_init(isc_hmacsha384_t *ctx, const unsigned char *key,
unsigned int len)
{
unsigned char ipad[ISC_SHA384_BLOCK_LENGTH];
unsigned int i;
memset(ctx->key, 0, sizeof(ctx->key));
if (len > sizeof(ctx->key)) {
isc_sha384_t sha384ctx;
isc_sha384_init(&sha384ctx);
isc_sha384_update(&sha384ctx, key, len);
isc_sha384_final(ctx->key, &sha384ctx);
} else
memcpy(ctx->key, key, len);
isc_sha384_init(&ctx->sha384ctx);
memset(ipad, IPAD, sizeof(ipad));
for (i = 0; i < ISC_SHA384_BLOCK_LENGTH; i++)
ipad[i] ^= ctx->key[i];
isc_sha384_update(&ctx->sha384ctx, ipad, sizeof(ipad));
}
void
isc_hmacsha384_invalidate(isc_hmacsha384_t *ctx) {
memset(ctx, 0, sizeof(*ctx));
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void
isc_hmacsha384_update(isc_hmacsha384_t *ctx, const unsigned char *buf,
unsigned int len)
{
isc_sha384_update(&ctx->sha384ctx, buf, len);
}
/*
* Compute signature - finalize SHA384 operation and reapply SHA384.
*/
void
isc_hmacsha384_sign(isc_hmacsha384_t *ctx, unsigned char *digest, size_t len) {
unsigned char opad[ISC_SHA384_BLOCK_LENGTH];
unsigned char newdigest[ISC_SHA384_DIGESTLENGTH];
unsigned int i;
REQUIRE(len <= ISC_SHA384_DIGESTLENGTH);
isc_sha384_final(newdigest, &ctx->sha384ctx);
memset(opad, OPAD, sizeof(opad));
for (i = 0; i < ISC_SHA384_BLOCK_LENGTH; i++)
opad[i] ^= ctx->key[i];
isc_sha384_init(&ctx->sha384ctx);
isc_sha384_update(&ctx->sha384ctx, opad, sizeof(opad));
isc_sha384_update(&ctx->sha384ctx, newdigest, ISC_SHA384_DIGESTLENGTH);
isc_sha384_final(newdigest, &ctx->sha384ctx);
memcpy(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
}
/*
* Start HMAC-SHA512 process. Initialize an sha512 context and digest the key.
*/
void
isc_hmacsha512_init(isc_hmacsha512_t *ctx, const unsigned char *key,
unsigned int len)
{
unsigned char ipad[ISC_SHA512_BLOCK_LENGTH];
unsigned int i;
memset(ctx->key, 0, sizeof(ctx->key));
if (len > sizeof(ctx->key)) {
isc_sha512_t sha512ctx;
isc_sha512_init(&sha512ctx);
isc_sha512_update(&sha512ctx, key, len);
isc_sha512_final(ctx->key, &sha512ctx);
} else
memcpy(ctx->key, key, len);
isc_sha512_init(&ctx->sha512ctx);
memset(ipad, IPAD, sizeof(ipad));
for (i = 0; i < ISC_SHA512_BLOCK_LENGTH; i++)
ipad[i] ^= ctx->key[i];
isc_sha512_update(&ctx->sha512ctx, ipad, sizeof(ipad));
}
void
isc_hmacsha512_invalidate(isc_hmacsha512_t *ctx) {
memset(ctx, 0, sizeof(*ctx));
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void
isc_hmacsha512_update(isc_hmacsha512_t *ctx, const unsigned char *buf,
unsigned int len)
{
isc_sha512_update(&ctx->sha512ctx, buf, len);
}
/*
* Compute signature - finalize SHA512 operation and reapply SHA512.
*/
void
isc_hmacsha512_sign(isc_hmacsha512_t *ctx, unsigned char *digest, size_t len) {
unsigned char opad[ISC_SHA512_BLOCK_LENGTH];
unsigned char newdigest[ISC_SHA512_DIGESTLENGTH];
unsigned int i;
REQUIRE(len <= ISC_SHA512_DIGESTLENGTH);
isc_sha512_final(newdigest, &ctx->sha512ctx);
memset(opad, OPAD, sizeof(opad));
for (i = 0; i < ISC_SHA512_BLOCK_LENGTH; i++)
opad[i] ^= ctx->key[i];
isc_sha512_init(&ctx->sha512ctx);
isc_sha512_update(&ctx->sha512ctx, opad, sizeof(opad));
isc_sha512_update(&ctx->sha512ctx, newdigest, ISC_SHA512_DIGESTLENGTH);
isc_sha512_final(newdigest, &ctx->sha512ctx);
memcpy(digest, newdigest, len);
memset(newdigest, 0, sizeof(newdigest));
}
#endif /* !ISC_PLATFORM_OPENSSLHASH */
/*
* Verify signature - finalize SHA1 operation and reapply SHA1, then
* compare to the supplied digest.
*/
isc_boolean_t
isc_hmacsha1_verify(isc_hmacsha1_t *ctx, unsigned char *digest, size_t len) {
unsigned char newdigest[ISC_SHA1_DIGESTLENGTH];
REQUIRE(len <= ISC_SHA1_DIGESTLENGTH);
isc_hmacsha1_sign(ctx, newdigest, ISC_SHA1_DIGESTLENGTH);
return (ISC_TF(isc_tsmemcmp(digest, newdigest, len) == 0));
}
/*
* Verify signature - finalize SHA224 operation and reapply SHA224, then
* compare to the supplied digest.
*/
isc_boolean_t
isc_hmacsha224_verify(isc_hmacsha224_t *ctx, unsigned char *digest, size_t len) {
unsigned char newdigest[ISC_SHA224_DIGESTLENGTH];
REQUIRE(len <= ISC_SHA224_DIGESTLENGTH);
isc_hmacsha224_sign(ctx, newdigest, ISC_SHA224_DIGESTLENGTH);
return (ISC_TF(isc_tsmemcmp(digest, newdigest, len) == 0));
}
/*
* Verify signature - finalize SHA256 operation and reapply SHA256, then
* compare to the supplied digest.
*/
isc_boolean_t
isc_hmacsha256_verify(isc_hmacsha256_t *ctx, unsigned char *digest, size_t len) {
unsigned char newdigest[ISC_SHA256_DIGESTLENGTH];
REQUIRE(len <= ISC_SHA256_DIGESTLENGTH);
isc_hmacsha256_sign(ctx, newdigest, ISC_SHA256_DIGESTLENGTH);
return (ISC_TF(isc_tsmemcmp(digest, newdigest, len) == 0));
}
/*
* Verify signature - finalize SHA384 operation and reapply SHA384, then
* compare to the supplied digest.
*/
isc_boolean_t
isc_hmacsha384_verify(isc_hmacsha384_t *ctx, unsigned char *digest, size_t len) {
unsigned char newdigest[ISC_SHA384_DIGESTLENGTH];
REQUIRE(len <= ISC_SHA384_DIGESTLENGTH);
isc_hmacsha384_sign(ctx, newdigest, ISC_SHA384_DIGESTLENGTH);
return (ISC_TF(isc_tsmemcmp(digest, newdigest, len) == 0));
}
/*
* Verify signature - finalize SHA512 operation and reapply SHA512, then
* compare to the supplied digest.
*/
isc_boolean_t
isc_hmacsha512_verify(isc_hmacsha512_t *ctx, unsigned char *digest, size_t len) {
unsigned char newdigest[ISC_SHA512_DIGESTLENGTH];
REQUIRE(len <= ISC_SHA512_DIGESTLENGTH);
isc_hmacsha512_sign(ctx, newdigest, ISC_SHA512_DIGESTLENGTH);
return (ISC_TF(isc_tsmemcmp(digest, newdigest, len) == 0));
}

File diff suppressed because it is too large Load Diff

View File

@ -1,100 +0,0 @@
/*
* Copyright (C) 2006, 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: atomic.h,v 1.7 2009/06/24 02:22:50 marka Exp $ */
#ifndef ISC_ATOMIC_H
#define ISC_ATOMIC_H 1
#include <isc/platform.h>
#include <isc/types.h>
#ifdef ISC_PLATFORM_USEGCCASM
/*
* This routine atomically increments the value stored in 'p' by 'val', and
* returns the previous value.
*
* Open issue: can 'fetchadd' make the code faster for some particular values
* (e.g., 1 and -1)?
*/
static inline isc_int32_t
#ifdef __GNUC__
__attribute__ ((unused))
#endif
isc_atomic_xadd(isc_int32_t *p, isc_int32_t val)
{
isc_int32_t prev, swapped;
for (prev = *(volatile isc_int32_t *)p; ; prev = swapped) {
swapped = prev + val;
__asm__ volatile(
"mov ar.ccv=%2;"
"cmpxchg4.acq %0=%4,%3,ar.ccv"
: "=r" (swapped), "=m" (*p)
: "r" (prev), "r" (swapped), "m" (*p)
: "memory");
if (swapped == prev)
break;
}
return (prev);
}
/*
* This routine atomically stores the value 'val' in 'p'.
*/
static inline void
#ifdef __GNUC__
__attribute__ ((unused))
#endif
isc_atomic_store(isc_int32_t *p, isc_int32_t val)
{
__asm__ volatile(
"st4.rel %0=%1"
: "=m" (*p)
: "r" (val)
: "memory"
);
}
/*
* This routine atomically replaces the value in 'p' with 'val', if the
* original value is equal to 'cmpval'. The original value is returned in any
* case.
*/
static inline isc_int32_t
#ifdef __GNUC__
__attribute__ ((unused))
#endif
isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val)
{
isc_int32_t ret;
__asm__ volatile(
"mov ar.ccv=%2;"
"cmpxchg4.acq %0=%4,%3,ar.ccv"
: "=r" (ret), "=m" (*p)
: "r" (cmpval), "r" (val), "m" (*p)
: "memory");
return (ret);
}
#else /* !ISC_PLATFORM_USEGCCASM */
#error "unsupported compiler. disable atomic ops by --disable-atomic"
#endif
#endif /* ISC_ATOMIC_H */

View File

@ -1,128 +0,0 @@
/*
* 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.3 2008/09/25 04:02:39 tbox 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 */

View File

@ -1,99 +0,0 @@
/*
* 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.22 2007/06/19 23:47:18 tbox 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 */

View File

@ -1,157 +0,0 @@
/*
* 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.14 2007/06/19 23:47:18 tbox 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 */

View File

@ -1,86 +0,0 @@
/*
* 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.17 2007/06/19 23:47:18 tbox 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 */

View File

@ -1,50 +0,0 @@
/*
* 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.16 2007/06/19 23:47:18 tbox 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 */

View File

@ -1,314 +0,0 @@
/*
* 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.35 2009/10/19 02:37:08 marka 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 */

View File

@ -1,178 +0,0 @@
/*
* 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.16 2009/01/17 23:47:43 tbox 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 */

View File

@ -1,170 +0,0 @@
/*
* 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.26 2009/01/17 23:47:43 tbox 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 */

View File

@ -1,98 +0,0 @@
/*
* 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.13 2008/09/25 04:02:39 tbox 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 */

View File

@ -1,72 +0,0 @@
/*
* 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.14 2009/02/06 23:47:42 tbox 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 */

View File

@ -1,169 +0,0 @@
/*
* 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.9 2009/02/06 23:47:42 tbox 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 */

View File

@ -1,64 +0,0 @@
/*
* 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.9 2008/08/08 05:06:49 marka 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 */

View File

@ -1,148 +0,0 @@
/*
* 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.24 2007/06/19 23:47:18 tbox 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>
/***
*** Types.
***/
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_IPV6_H */

View File

@ -1,47 +0,0 @@
/*
* 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.3 2008/09/25 04:02:39 tbox 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 */

View File

@ -1,431 +0,0 @@
/*
* 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.37 2008/05/30 23:47:01 tbox 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 */

View File

@ -1,130 +0,0 @@
/*
* 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.17 2007/06/19 23:47:18 tbox 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 */

View File

@ -1,750 +0,0 @@
/*
* 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$ */
#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>
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
#endif /* ISC_MEM_H */

View File

@ -1,71 +0,0 @@
/*
* 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.17 2007/06/19 23:47:18 tbox 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 */

View File

@ -1,38 +0,0 @@
/*
* 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.12 2007/06/19 23:47:18 tbox 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 */

View File

@ -1,64 +0,0 @@
/*
* 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.9 2007/06/19 23:47:18 tbox 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 */

View File

@ -1,367 +0,0 @@
/*
* Copyright (C) 2004-2010 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: platform.h.in,v 1.56 2010/12/18 01:56:23 each Exp $ */
#ifndef ISC_PLATFORM_H
#define ISC_PLATFORM_H 1
/*! \file */
/*****
***** Platform-dependent defines.
*****/
/***
*** Network.
***/
/*! \brief
* Define if this system needs the <netinet/in6.h> header file included
* for full IPv6 support (pretty much only UnixWare).
*/
@ISC_PLATFORM_NEEDNETINETIN6H@
/*! \brief
* Define if this system needs the <netinet6/in6.h> header file included
* to support in6_pkinfo (pretty much only BSD/OS).
*/
@ISC_PLATFORM_NEEDNETINET6IN6H@
/*! \brief
* If sockaddrs on this system have an sa_len field, ISC_PLATFORM_HAVESALEN
* will be defined.
*/
@ISC_PLATFORM_HAVESALEN@
/*! \brief
* If this system has the IPv6 structure definitions, ISC_PLATFORM_HAVEIPV6
* will be defined.
*/
@ISC_PLATFORM_HAVEIPV6@
/*! \brief
* If this system is missing in6addr_any, ISC_PLATFORM_NEEDIN6ADDRANY will
* be defined.
*/
@ISC_PLATFORM_NEEDIN6ADDRANY@
/*! \brief
* If this system is missing in6addr_loopback, ISC_PLATFORM_NEEDIN6ADDRLOOPBACK
* will be defined.
*/
@ISC_PLATFORM_NEEDIN6ADDRLOOPBACK@
/*! \brief
* If this system has in6_pktinfo, ISC_PLATFORM_HAVEIN6PKTINFO will be
* defined.
*/
@ISC_PLATFORM_HAVEIN6PKTINFO@
/*! \brief
* If this system has in_addr6, rather than in6_addr, ISC_PLATFORM_HAVEINADDR6
* will be defined.
*/
@ISC_PLATFORM_HAVEINADDR6@
/*! \brief
* If this system has sin6_scope_id, ISC_PLATFORM_HAVESCOPEID will be defined.
*/
@ISC_PLATFORM_HAVESCOPEID@
/*! \brief
* If this system needs inet_ntop(), ISC_PLATFORM_NEEDNTOP will be defined.
*/
@ISC_PLATFORM_NEEDNTOP@
/*! \brief
* If this system needs inet_pton(), ISC_PLATFORM_NEEDPTON will be defined.
*/
@ISC_PLATFORM_NEEDPTON@
/*! \brief
* If this system needs in_port_t, ISC_PLATFORM_NEEDPORTT will be defined.
*/
@ISC_PLATFORM_NEEDPORTT@
/*! \brief
* Define if the system has struct lifconf which is a extended struct ifconf
* for IPv6.
*/
@ISC_PLATFORM_HAVELIFCONF@
/*! \brief
* Define if the system has struct if_laddrconf which is a extended struct
* ifconf for IPv6.
*/
@ISC_PLATFORM_HAVEIF_LADDRCONF@
/*! \brief
* Define if the system has struct if_laddrreq.
*/
@ISC_PLATFORM_HAVEIF_LADDRREQ@
/*! \brief
* Define either ISC_PLATFORM_BSD44MSGHDR or ISC_PLATFORM_BSD43MSGHDR.
*/
@ISC_PLATFORM_MSGHDRFLAVOR@
/*! \brief
* Define if the system supports if_nametoindex.
*/
@ISC_PLATFORM_HAVEIFNAMETOINDEX@
/*! \brief
* Define on some UnixWare systems to fix erroneous definitions of various
* IN6_IS_ADDR_* macros.
*/
@ISC_PLATFORM_FIXIN6ISADDR@
/*! \brief
* Define if the system supports kqueue multiplexing
*/
@ISC_PLATFORM_HAVEKQUEUE@
/*! \brief
* Define if the system supports epoll multiplexing
*/
@ISC_PLATFORM_HAVEEPOLL@
/*! \brief
* Define if the system supports /dev/poll multiplexing
*/
@ISC_PLATFORM_HAVEDEVPOLL@
/*! \brief
* Define if we want to log backtrace
*/
@ISC_PLATFORM_USEBACKTRACE@
/*
*** Printing.
***/
/*! \brief
* If this system needs vsnprintf() and snprintf(), ISC_PLATFORM_NEEDVSNPRINTF
* will be defined.
*/
@ISC_PLATFORM_NEEDVSNPRINTF@
/*! \brief
* If this system need a modern sprintf() that returns (int) not (char*).
*/
@ISC_PLATFORM_NEEDSPRINTF@
/*! \brief
* The printf format string modifier to use with isc_uint64_t values.
*/
@ISC_PLATFORM_QUADFORMAT@
/***
*** String functions.
***/
/*
* If the system needs strsep(), ISC_PLATFORM_NEEDSTRSEP will be defined.
*/
@ISC_PLATFORM_NEEDSTRSEP@
/*
* If the system needs strlcpy(), ISC_PLATFORM_NEEDSTRLCPY will be defined.
*/
@ISC_PLATFORM_NEEDSTRLCPY@
/*
* If the system needs strlcat(), ISC_PLATFORM_NEEDSTRLCAT will be defined.
*/
@ISC_PLATFORM_NEEDSTRLCAT@
/*
* Define if this system needs strtoul.
*/
@ISC_PLATFORM_NEEDSTRTOUL@
/*
* Define if this system needs memmove.
*/
@ISC_PLATFORM_NEEDMEMMOVE@
/***
*** Miscellaneous.
***/
/*
* Defined if we are using threads.
*/
@ISC_PLATFORM_USETHREADS@
/*
* Defined if unistd.h does not cause fd_set to be delared.
*/
@ISC_PLATFORM_NEEDSYSSELECTH@
/*
* Defined to <gssapi.h> or <gssapi/gssapi.h> for how to include
* the GSSAPI header.
*/
@ISC_PLATFORM_GSSAPIHEADER@
/*
* Defined to <gssapi_krb5.h> or <gssapi/gssapi_krb5.h> for how to
* include the GSSAPI KRB5 header.
*/
@ISC_PLATFORM_GSSAPI_KRB5_HEADER@
/*
* Defined to <krb5.h> or <krb5/krb5.h> for how to include
* the KRB5 header.
*/
@ISC_PLATFORM_KRB5HEADER@
/*
* Type used for resource limits.
*/
@ISC_PLATFORM_RLIMITTYPE@
/*
* Define if your compiler supports "long long int".
*/
@ISC_PLATFORM_HAVELONGLONG@
/*
* Define if PTHREAD_ONCE_INIT should be surrounded by braces to
* prevent compiler warnings (such as with gcc on Solaris 2.8).
*/
@ISC_PLATFORM_BRACEPTHREADONCEINIT@
/*
* Used to control how extern data is linked; needed for Win32 platforms.
*/
@ISC_PLATFORM_USEDECLSPEC@
/*
* Define if the platform has <sys/un.h>.
*/
@ISC_PLATFORM_HAVESYSUNH@
/*
* If the "xadd" operation is available on this architecture,
* ISC_PLATFORM_HAVEXADD will be defined.
*/
@ISC_PLATFORM_HAVEXADD@
/*
* If the "xaddq" operation (64bit xadd) is available on this architecture,
* ISC_PLATFORM_HAVEXADDQ will be defined.
*/
@ISC_PLATFORM_HAVEXADDQ@
/*
* If the "atomic swap" operation is available on this architecture,
* ISC_PLATFORM_HAVEATOMICSTORE" will be defined.
*/
@ISC_PLATFORM_HAVEATOMICSTORE@
/*
* If the "compare-and-exchange" operation is available on this architecture,
* ISC_PLATFORM_HAVECMPXCHG will be defined.
*/
@ISC_PLATFORM_HAVECMPXCHG@
/*
* Define if gcc ASM extension is available
*/
@ISC_PLATFORM_USEGCCASM@
/*
* Define if Tru64 style ASM syntax must be used.
*/
@ISC_PLATFORM_USEOSFASM@
/*
* Define if the standard __asm function must be used.
*/
@ISC_PLATFORM_USESTDASM@
/*
* Define if the platform has <strings.h>.
*/
@ISC_PLATFORM_HAVESTRINGSH@
/*
* Define if the hash functions must be provided by OpenSSL.
*/
@ISC_PLATFORM_OPENSSLHASH@
/*
* Defines for the noreturn attribute.
*/
@ISC_PLATFORM_NORETURN_PRE@
@ISC_PLATFORM_NORETURN_POST@
/***
*** Windows dll support.
***/
/*
* Define if MacOS style of PPC assembly must be used.
* e.g. "r6", not "6", for register six.
*/
@ISC_PLATFORM_USEMACASM@
#ifndef ISC_PLATFORM_USEDECLSPEC
#define LIBISC_EXTERNAL_DATA
#define LIBDNS_EXTERNAL_DATA
#define LIBISCCC_EXTERNAL_DATA
#define LIBISCCFG_EXTERNAL_DATA
#define LIBBIND9_EXTERNAL_DATA
#else /*! \brief ISC_PLATFORM_USEDECLSPEC */
#ifdef LIBISC_EXPORTS
#define LIBISC_EXTERNAL_DATA __declspec(dllexport)
#else
#define LIBISC_EXTERNAL_DATA __declspec(dllimport)
#endif
#ifdef LIBDNS_EXPORTS
#define LIBDNS_EXTERNAL_DATA __declspec(dllexport)
#else
#define LIBDNS_EXTERNAL_DATA __declspec(dllimport)
#endif
#ifdef LIBISCCC_EXPORTS
#define LIBISCCC_EXTERNAL_DATA __declspec(dllexport)
#else
#define LIBISCCC_EXTERNAL_DATA __declspec(dllimport)
#endif
#ifdef LIBISCCFG_EXPORTS
#define LIBISCCFG_EXTERNAL_DATA __declspec(dllexport)
#else
#define LIBISCCFG_EXTERNAL_DATA __declspec(dllimport)
#endif
#ifdef LIBBIND9_EXPORTS
#define LIBBIND9_EXTERNAL_DATA __declspec(dllexport)
#else
#define LIBBIND9_EXTERNAL_DATA __declspec(dllimport)
#endif
#endif /*! \brief ISC_PLATFORM_USEDECLSPEC */
/*
* Tell emacs to use C mode for this file.
*
* Local Variables:
* mode: c
* End:
*/
#endif /* ISC_PLATFORM_H */

View File

@ -1,141 +0,0 @@
/*
* 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.6 2009/06/25 05:28:34 marka 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 */

View File

@ -1,100 +0,0 @@
/*
* 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$ */
/*
* 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 */

View File

@ -1,119 +0,0 @@
/*
* 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.16 2007/06/19 23:47:18 tbox 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 */

View File

@ -1,240 +0,0 @@
/*
* 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.13 2008/12/01 23:47:45 tbox 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 */

View File

@ -1,134 +0,0 @@
/*
* 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.23 2009/01/18 23:48:14 tbox 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 */

View File

@ -1,233 +0,0 @@
/*
* 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.17 2009/09/29 23:48:04 tbox 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 */

View File

@ -1,97 +0,0 @@
/*
* 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.13 2008/07/11 23:47:09 tbox 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 */

View File

@ -1,135 +0,0 @@
/*
* 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.28 2007/06/19 23:47:18 tbox 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 */

View File

@ -1,75 +0,0 @@
/*
* 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.18 2009/01/18 23:48:14 tbox 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 */

View File

@ -1,145 +0,0 @@
/*
* 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.12 2009/10/22 02:21:31 each 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 */

View File

@ -1,121 +0,0 @@
/*
* 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$ */
#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 */

View File

@ -1,40 +0,0 @@
/*
* 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.8 2007/06/19 23:47:18 tbox 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

View File

@ -1,139 +0,0 @@
/*
* 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$ */
#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 */

View File

@ -1,157 +0,0 @@
/*
* 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$ */
#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 */

View File

@ -1,28 +0,0 @@
/*
* 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.9 2007/06/19 23:47:18 tbox 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