Browse Source

Merge branch 'master' of git+ssh://bind10.isc.org/var/bind10/git/bind10

Michal 'vorner' Vaner 14 years ago
parent
commit
9c846eb198
65 changed files with 1593 additions and 772 deletions
  1. 3 0
      configure.ac
  2. 1 1
      src/bin/Makefile.am
  3. 10 2
      src/bin/bind10/bind10.py.in
  4. 2 2
      src/bin/bind10/run_bind10.sh.in
  5. 67 0
      src/bin/bind10/tests/bind10_test.py.in
  6. 7 5
      src/bin/cfgmgr/b10-cfgmgr.py.in
  7. 1 1
      src/bin/cfgmgr/tests/Makefile.am
  8. 9 0
      src/bin/dhcp6/.gitignore
  9. 52 0
      src/bin/dhcp6/Makefile.am
  10. 50 0
      src/bin/dhcp6/b10-dhcp6.8
  11. 213 0
      src/bin/dhcp6/dhcp6.h
  12. 14 0
      src/bin/dhcp6/dhcp6.spec
  13. 122 0
      src/bin/dhcp6/main.cc
  14. 15 0
      src/bin/dhcp6/spec_config.h.pre.in
  15. 22 0
      src/bin/dhcp6/tests/Makefile.am
  16. 65 0
      src/bin/dhcp6/tests/dhcp6_test.py
  17. 2 2
      src/bin/resolver/resolver.cc
  18. 1 0
      src/bin/resolver/tests/Makefile.am
  19. 14 0
      src/lib/acl/loader.h
  20. 4 4
      src/lib/log/Makefile.am
  21. 190 131
      src/lib/log/README
  22. 5 5
      src/lib/log/compiler/message.cc
  23. 0 29
      src/lib/log/impldef.cc
  24. 0 18
      src/lib/log/impldef.h
  25. 0 38
      src/lib/log/impldef.mes
  26. 63 0
      src/lib/log/log_messages.cc
  27. 35 0
      src/lib/log/log_messages.h
  28. 146 0
      src/lib/log/log_messages.mes
  29. 2 2
      src/lib/log/logger_level.cc
  30. 4 4
      src/lib/log/logger_level_impl.cc
  31. 8 9
      src/lib/log/logger_manager.cc
  32. 7 7
      src/lib/log/logger_manager_impl.cc
  33. 29 0
      src/lib/log/logimpl_messages.cc
  34. 18 0
      src/lib/log/logimpl_messages.h
  35. 43 0
      src/lib/log/logimpl_messages.mes
  36. 14 14
      src/lib/log/message_reader.cc
  37. 0 63
      src/lib/log/messagedef.cc
  38. 0 35
      src/lib/log/messagedef.h
  39. 0 131
      src/lib/log/messagedef.mes
  40. 6 5
      src/lib/log/output_option.cc
  41. 12 12
      src/lib/log/tests/destination_test.sh.in
  42. 19 19
      src/lib/log/tests/local_file_test.sh.in
  43. 16 16
      src/lib/log/tests/logger_example.cc
  44. 1 1
      src/lib/log/tests/logger_level_unittest.cc
  45. 19 19
      src/lib/log/tests/logger_manager_unittest.cc
  46. 3 3
      src/lib/log/tests/logger_support_unittest.cc
  47. 1 1
      src/lib/log/tests/logger_unittest.cc
  48. 2 2
      src/lib/log/tests/message_dictionary_unittest.cc
  49. 12 12
      src/lib/log/tests/message_reader_unittest.cc
  50. 26 26
      src/lib/log/tests/severity_test.sh.in
  51. 7 7
      src/lib/nsas/Makefile.am
  52. 2 3
      src/lib/nsas/nameserver_address_store.cc
  53. 6 6
      src/lib/nsas/nameserver_entry.cc
  54. 1 1
      src/lib/nsas/nsas_log.h
  55. 69 0
      src/lib/nsas/nsas_messages.mes
  56. 0 61
      src/lib/nsas/nsasdef.mes
  57. 9 0
      src/lib/python/isc/config/Makefile.am
  58. 27 9
      src/lib/python/isc/config/cfgmgr.py
  59. 50 0
      src/lib/python/isc/config/cfgmgr_messages.mes
  60. 1 1
      src/lib/python/isc/config/tests/Makefile.am
  61. 6 6
      src/lib/resolve/Makefile.am
  62. 21 21
      src/lib/resolve/recursive_query.cc
  63. 1 1
      src/lib/resolve/resolve_log.h
  64. 36 37
      src/lib/resolve/resolvedef.mes
  65. 2 0
      src/lib/server_common/tests/Makefile.am

+ 3 - 0
configure.ac

@@ -775,6 +775,8 @@ AC_CONFIG_FILES([Makefile
                  src/bin/auth/Makefile
                  src/bin/auth/tests/Makefile
                  src/bin/auth/benchmarks/Makefile
+                 src/bin/dhcp6/Makefile
+                 src/bin/dhcp6/tests/Makefile
                  src/bin/resolver/Makefile
                  src/bin/resolver/tests/Makefile
                  src/bin/sockcreator/Makefile
@@ -904,6 +906,7 @@ AC_OUTPUT([doc/version.ent
            src/bin/msgq/run_msgq.sh
            src/bin/auth/auth.spec.pre
            src/bin/auth/spec_config.h.pre
+           src/bin/dhcp6/spec_config.h.pre
            src/bin/tests/process_rename_test.py
            src/lib/config/tests/data_def_unittests_config.h
            src/lib/python/isc/config/tests/config_test

+ 1 - 1
src/bin/Makefile.am

@@ -1,4 +1,4 @@
 SUBDIRS = bind10 bindctl cfgmgr loadzone msgq host cmdctl auth xfrin xfrout \
-	usermgr zonemgr stats tests resolver sockcreator
+	usermgr zonemgr stats tests resolver sockcreator dhcp6 
 
 check-recursive: all-recursive

+ 10 - 2
src/bin/bind10/bind10.py.in

@@ -220,6 +220,8 @@ class BoB:
         self.ccs = None
         self.cfg_start_auth = True
         self.cfg_start_resolver = False
+        self.cfg_start_dhcp6 = False
+        self.cfg_start_dhcp4 = False
         self.started_auth_family = False
         self.started_resolver_family = False
         self.curproc = None
@@ -549,6 +551,9 @@ class BoB:
     def start_stats_httpd(self, c_channel_env):
         self.start_simple("b10-stats-httpd", c_channel_env)
 
+    def start_dhcp6(self, c_channel_env):
+        self.start_simple("b10-dhcp6", c_channel_env)
+
     def start_cmdctl(self, c_channel_env):
         """
             Starts the command control process
@@ -600,11 +605,14 @@ class BoB:
         self.start_stats(c_channel_env)
         self.start_stats_httpd(c_channel_env)
         self.start_cmdctl(c_channel_env)
-    
+
+        if self.cfg_start_dhcp6:
+            self.start_dhcp6(c_channel_env)
+
     def startup(self):
         """
             Start the BoB instance.
- 
+
             Returns None if successful, otherwise an string describing the
             problem.
         """

+ 2 - 2
src/bin/bind10/run_bind10.sh.in

@@ -20,10 +20,10 @@ export PYTHON_EXEC
 
 BIND10_PATH=@abs_top_builddir@/src/bin/bind10
 
-PATH=@abs_top_builddir@/src/bin/msgq:@abs_top_builddir@/src/bin/auth:@abs_top_builddir@/src/bin/resolver:@abs_top_builddir@/src/bin/cfgmgr:@abs_top_builddir@/src/bin/cmdctl:@abs_top_builddir@/src/bin/stats:@abs_top_builddir@/src/bin/xfrin:@abs_top_builddir@/src/bin/xfrout:@abs_top_builddir@/src/bin/zonemgr:$PATH
+PATH=@abs_top_builddir@/src/bin/msgq:@abs_top_builddir@/src/bin/auth:@abs_top_builddir@/src/bin/resolver:@abs_top_builddir@/src/bin/cfgmgr:@abs_top_builddir@/src/bin/cmdctl:@abs_top_builddir@/src/bin/stats:@abs_top_builddir@/src/bin/xfrin:@abs_top_builddir@/src/bin/xfrout:@abs_top_builddir@/src/bin/zonemgr:@abs_top_builddir@/src/bin/dhcp6:$PATH
 export PATH
 
-PYTHONPATH=@abs_top_builddir@/src/lib/python:@abs_top_builddir@/src/lib/dns/python/.libs:@abs_top_builddir@/src/lib/xfr/.libs:@abs_top_builddir@/src/lib/log/.libs:@abs_top_builddir@/src/lib/util/io/.libs
+PYTHONPATH=@abs_top_builddir@/src/lib/python:@abs_top_builddir@/src/lib/dns/python/.libs:@abs_top_builddir@/src/lib/xfr/.libs:@abs_top_builddir@/src/lib/log/.libs:@abs_top_builddir@/src/lib/util/io/.libs:@abs_top_builddir@/src/lib/python/isc/config
 export PYTHONPATH
 
 # If necessary (rare cases), explicitly specify paths to dynamic libraries

+ 67 - 0
src/bin/bind10/tests/bind10_test.py.in

@@ -111,6 +111,9 @@ class TestBoB(unittest.TestCase):
         self.assertEqual(bob.cfg_start_auth, True)
         self.assertEqual(bob.cfg_start_resolver, False)
 
+        self.assertEqual(bob.cfg_start_dhcp4, False)
+        self.assertEqual(bob.cfg_start_dhcp6, False)
+
     def test_init_alternate_socket(self):
         bob = BoB("alt_socket_file")
         self.assertEqual(bob.verbose, False)
@@ -125,6 +128,8 @@ class TestBoB(unittest.TestCase):
         self.assertEqual(bob.nocache, False)
         self.assertEqual(bob.cfg_start_auth, True)
         self.assertEqual(bob.cfg_start_resolver, False)
+        self.assertEqual(bob.cfg_start_dhcp4, False)
+        self.assertEqual(bob.cfg_start_dhcp6, False)
 
     def test_command_handler(self):
         class DummySession():
@@ -247,6 +252,16 @@ class MockBob(BoB):
         self.processes[12] = ProcessInfo('b10-cmdctl', ['/bin/false'])
         self.processes[12].pid = 12
 
+    def start_dhcp6(self, c_channel_env):
+        self.dhcp6 = True
+        self.processes[13] = ProcessInfo('b10-dhcp6', ['/bin/false'])
+        self.processes[13]
+
+    def start_dhcp4(self, c_channel_env):
+        self.dhcp4 = True
+        self.processes[14] = ProcessInfo('b10-dhcp4', ['/bin/false'])
+        self.processes[14]
+
     # We don't really use all of these stop_ methods. But it might turn out
     # someone would add some stop_ method to BoB and we want that one overriden
     # in case he forgets to update the tests.
@@ -359,6 +374,24 @@ class TestStartStopProcessesBob(unittest.TestCase):
         """
         self.check_started(bob, True, False, True)
 
+    def check_started_dhcp(self, bob, v4, v6):
+        """
+        Check if proper combinations of DHCPv4 and DHCpv6 can be started
+        """
+        v4found = 0
+        v6found = 0
+
+        for pid in bob.processes:
+            if (bob.processes[pid].name == "b10-dhcp4"):
+                v4found += 1
+            if (bob.processes[pid].name == "b10-dhcp6"):
+                v6found += 1
+
+        # there should be exactly one DHCPv4 daemon (if v4==True)
+        # there should be exactly one DHCPv6 daemon (if v6==True)
+        self.assertEqual(v4==True, v4found==1)
+        self.assertEqual(v6==True, v6found==1)
+
     # Checks the processes started when starting neither auth nor resolver
     # is specified.
     def test_start_none(self):
@@ -524,6 +557,40 @@ class TestStartStopProcessesBob(unittest.TestCase):
 
         bob.config_handler({'start_auth': True, 'start_resolver': True})
 
+    # Checks that DHCP (v4 and v6) processes are started when expected
+    def test_start_dhcp(self):
+
+        # Create BoB and ensure correct initialization
+        bob = MockBob()
+        self.check_preconditions(bob)
+
+        # don't care about DNS stuff
+        bob.cfg_start_auth = False
+        bob.cfg_start_resolver = False
+
+        # v4 and v6 disabled
+        bob.cfg_start_dhcp6 = False
+        bob.cfg_start_dhcp4 = False
+        bob.start_all_processes()
+        self.check_started_dhcp(bob, False, False)
+
+        # v6 only enabled
+        bob.cfg_start_dhcp6 = True
+        bob.cfg_start_dhcp4 = False
+        bob.start_all_processes()
+        self.check_started_dhcp(bob, False, True)
+
+        # uncomment when dhcpv4 becomes implemented
+        # v4 only enabled
+        #bob.cfg_start_dhcp6 = False
+        #bob.cfg_start_dhcp4 = True
+        #self.check_started_dhcp(bob, True, False)
+
+        # both v4 and v6 enabled
+        #bob.cfg_start_dhcp6 = True
+        #bob.cfg_start_dhcp4 = True
+        #self.check_started_dhcp(bob, True, True)
+
 class TestBossCmd(unittest.TestCase):
     def test_ping(self):
         """

+ 7 - 5
src/bin/cfgmgr/b10-cfgmgr.py.in

@@ -17,7 +17,6 @@
 
 import sys; sys.path.append ('@@PYTHONPATH@@')
 
-from isc.config.cfgmgr import ConfigManager, ConfigManagerDataReadError
 import bind10_config
 from isc.cc import SessionError
 import isc.util.process
@@ -26,6 +25,10 @@ import os
 from optparse import OptionParser
 import glob
 import os.path
+import isc.log
+isc.log.init("b10-cfgmgr")
+from isc.config.cfgmgr import ConfigManager, ConfigManagerDataReadError, logger
+from cfgmgr_messages import *
 
 isc.util.process.rename()
 
@@ -91,13 +94,12 @@ def main():
         cm.notify_boss()
         cm.run()
     except SessionError as se:
-        print("[b10-cfgmgr] Error creating config manager, "
-              "is the command channel daemon running?")
+        logger.fatal(CFGMGR_CC_SESSION_ERROR, se)
         return 1
     except KeyboardInterrupt as kie:
-        print("[b10-cfgmgr] Interrupted, exiting")
+        logger.info(CFGMGR_STOPPED_BY_KEYBOARD)
     except ConfigManagerDataReadError as cmdre:
-        print("[b10-cfgmgr] " + str(cmdre))
+        logger.fatal(CFGMGR_DATA_READ_ERROR, cmdre)
         return 2
     return 0
 

+ 1 - 1
src/bin/cfgmgr/tests/Makefile.am

@@ -21,7 +21,7 @@ endif
 	echo Running test: $$pytest ; \
 	env TESTDATA_PATH=$(abs_srcdir)/testdata \
 	$(LIBRARY_PATH_PLACEHOLDER) \
-	env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/bin/cfgmgr \
+	env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/bin/cfgmgr:$(abs_top_builddir)/src/lib/python/isc/config \
 	$(PYCOVERAGE_RUN) $(abs_builddir)/$$pytest || exit ; \
 	done
 

+ 9 - 0
src/bin/dhcp6/.gitignore

@@ -0,0 +1,9 @@
+*~
+Makefile
+Makefile.in
+*.o
+.deps
+.libs
+b10-dhcp6
+spec_config.h
+spec_config.h.pre

+ 52 - 0
src/bin/dhcp6/Makefile.am

@@ -0,0 +1,52 @@
+SUBDIRS = . tests
+
+AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
+AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
+AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
+AM_CPPFLAGS += -I$(top_srcdir)/src/lib/cc -I$(top_builddir)/src/lib/cc
+AM_CPPFLAGS += -I$(top_srcdir)/src/lib/asiolink
+AM_CPPFLAGS += -I$(top_builddir)/src/lib/asiolink
+AM_CPPFLAGS += $(BOOST_INCLUDES)
+
+AM_CXXFLAGS = $(B10_CXXFLAGS)
+
+if USE_STATIC_LINK
+AM_LDFLAGS = -static
+endif
+
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+
+CLEANFILES = *.gcno *.gcda spec_config.h
+
+man_MANS = b10-dhcp6.8
+EXTRA_DIST = $(man_MANS) dhcp6.spec
+
+#if ENABLE_MAN
+#b10-dhcp6.8: b10-dhcp6.xml
+#	xsltproc --novalid --xinclude --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $(srcdir)/b10-dhcp6.xml
+#endif
+
+spec_config.h: spec_config.h.pre
+	$(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" spec_config.h.pre >$@
+
+BUILT_SOURCES = spec_config.h
+pkglibexec_PROGRAMS = b10-dhcp6
+b10_dhcp6_SOURCES = main.cc
+b10_dhcp6_SOURCES += dhcp6.h
+b10_dhcp6_LDADD =  $(top_builddir)/src/lib/datasrc/libdatasrc.la
+b10_dhcp6_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
+b10_dhcp6_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
+b10_dhcp6_LDADD += $(top_builddir)/src/lib/cc/libcc.la
+b10_dhcp6_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
+b10_dhcp6_LDADD += $(top_builddir)/src/lib/asiodns/libasiodns.la
+b10_dhcp6_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
+b10_dhcp6_LDADD += $(top_builddir)/src/lib/log/liblog.la
+b10_dhcp6_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
+b10_dhcp6_LDADD += $(top_builddir)/src/lib/server_common/libserver_common.la
+b10_dhcp6_LDADD += $(SQLITE_LIBS)
+
+# TODO: config.h.in is wrong because doesn't honor pkgdatadir
+# and can't use @datadir@ because doesn't expand default ${prefix}
+b10_dhcp6dir = $(pkgdatadir)
+b10_dhcp6_DATA = dhcp6.spec
+

+ 50 - 0
src/bin/dhcp6/b10-dhcp6.8

@@ -0,0 +1,50 @@
+'\" t
+.\"     Title: b10-dhpc6
+.\"    Author: [FIXME: author] [see http://docbook.sf.net/el/author]
+.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
+.\"      Date: March 8, 2011
+.\"    Manual: BIND10
+.\"    Source: BIND10
+.\"  Language: English
+.\"
+.TH "B10\-DHCP6" "8" "March 8, 2011" "BIND10" "BIND10"
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+b10-dhcp6 \- DHCPv6 daemon in BIND10 architecture
+.SH "SYNOPSIS"
+.HP \w'\fBb10\-dhcp6\fR\ 'u
+\fBb10\-dhcp6\fR [\fB\-u\ \fR\fB\fIusername\fR\fR] [\fB\-v\fR]
+.SH "DESCRIPTION"
+.PP
+The
+\fBb10\-dhcp6\fR
+daemon will provide DHCPv6 server implementation when it becomes functional.
+.PP
+.SH "SEE ALSO"
+.PP
+
+\fBb10-cfgmgr\fR(8),
+\fBb10-loadzone\fR(8),
+\fBb10-msgq\fR(8),
+\fBb10-stats\fR(8),
+\fBb10-zonemgr\fR(8),
+\fBbind10\fR(8),
+BIND 10 Guide\&.
+.SH "HISTORY"
+.PP
+The
+\fBb10\-dhcp6\fR
+daemon was first coded in June 2011\&.
+.SH "COPYRIGHT"
+.br
+Copyright \(co 2011 Internet Systems Consortium, Inc. ("ISC")
+.br

+ 213 - 0
src/bin/dhcp6/dhcp6.h

@@ -0,0 +1,213 @@
+/* dhcp6.h
+
+   DHCPv6 Protocol structures... */
+
+/*
+ * Copyright (c) 2006-2011 by Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND 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.
+ *
+ *   Internet Systems Consortium, Inc.
+ *   950 Charter Street
+ *   Redwood City, CA 94063
+ *   <info@isc.org>
+ *   https://www.isc.org/
+ */
+
+
+/* DHCPv6 Option codes: */
+
+#define D6O_CLIENTID				1 /* RFC3315 */
+#define D6O_SERVERID				2
+#define D6O_IA_NA				3
+#define D6O_IA_TA				4
+#define D6O_IAADDR				5
+#define D6O_ORO					6
+#define D6O_PREFERENCE				7
+#define D6O_ELAPSED_TIME			8
+#define D6O_RELAY_MSG				9
+/* Option code 10 unassigned. */
+#define D6O_AUTH				11
+#define D6O_UNICAST				12
+#define D6O_STATUS_CODE				13
+#define D6O_RAPID_COMMIT			14
+#define D6O_USER_CLASS				15
+#define D6O_VENDOR_CLASS			16
+#define D6O_VENDOR_OPTS				17
+#define D6O_INTERFACE_ID			18
+#define D6O_RECONF_MSG				19
+#define D6O_RECONF_ACCEPT			20
+#define D6O_SIP_SERVERS_DNS			21 /* RFC3319 */
+#define D6O_SIP_SERVERS_ADDR			22 /* RFC3319 */
+#define D6O_NAME_SERVERS			23 /* RFC3646 */
+#define D6O_DOMAIN_SEARCH			24 /* RFC3646 */
+#define D6O_IA_PD				25 /* RFC3633 */
+#define D6O_IAPREFIX				26 /* RFC3633 */
+#define D6O_NIS_SERVERS				27 /* RFC3898 */
+#define D6O_NISP_SERVERS			28 /* RFC3898 */
+#define D6O_NIS_DOMAIN_NAME			29 /* RFC3898 */
+#define D6O_NISP_DOMAIN_NAME			30 /* RFC3898 */
+#define D6O_SNTP_SERVERS			31 /* RFC4075 */
+#define D6O_INFORMATION_REFRESH_TIME		32 /* RFC4242 */
+#define D6O_BCMCS_SERVER_D			33 /* RFC4280 */
+#define D6O_BCMCS_SERVER_A			34 /* RFC4280 */
+/* 35 is unassigned */
+#define D6O_GEOCONF_CIVIC			36 /* RFC4776 */
+#define D6O_REMOTE_ID				37 /* RFC4649 */
+#define D6O_SUBSCRIBER_ID			38 /* RFC4580 */
+#define D6O_CLIENT_FQDN				39 /* RFC4704 */
+#define D6O_PANA_AGENT				40 /* paa-option */
+#define D6O_NEW_POSIX_TIMEZONE			41 /* RFC4833 */
+#define D6O_NEW_TZDB_TIMEZONE			42 /* RFC4833 */
+#define D6O_ERO					43 /* RFC4994 */
+#define D6O_LQ_QUERY				44 /* RFC5007 */
+#define D6O_CLIENT_DATA				45 /* RFC5007 */
+#define D6O_CLT_TIME				46 /* RFC5007 */
+#define D6O_LQ_RELAY_DATA			47 /* RFC5007 */
+#define D6O_LQ_CLIENT_LINK			48 /* RFC5007 */
+
+/* 
+ * Status Codes, from RFC 3315 section 24.4, and RFC 3633, 5007.
+ */
+#define STATUS_Success		 0
+#define STATUS_UnspecFail	 1
+#define STATUS_NoAddrsAvail	 2
+#define STATUS_NoBinding	 3
+#define STATUS_NotOnLink	 4 
+#define STATUS_UseMulticast	 5 
+#define STATUS_NoPrefixAvail	 6
+#define STATUS_UnknownQueryType	 7
+#define STATUS_MalformedQuery	 8
+#define STATUS_NotConfigured	 9
+#define STATUS_NotAllowed	10
+
+/* 
+ * DHCPv6 message types, defined in section 5.3 of RFC 3315 
+ */
+#define DHCPV6_SOLICIT		    1
+#define DHCPV6_ADVERTISE	    2
+#define DHCPV6_REQUEST		    3
+#define DHCPV6_CONFIRM		    4
+#define DHCPV6_RENEW		    5
+#define DHCPV6_REBIND		    6
+#define DHCPV6_REPLY		    7
+#define DHCPV6_RELEASE		    8
+#define DHCPV6_DECLINE		    9
+#define DHCPV6_RECONFIGURE	   10
+#define DHCPV6_INFORMATION_REQUEST 11
+#define DHCPV6_RELAY_FORW	   12
+#define DHCPV6_RELAY_REPL	   13
+#define DHCPV6_LEASEQUERY	   14
+#define DHCPV6_LEASEQUERY_REPLY    15
+
+extern const char *dhcpv6_type_names[];
+extern const int dhcpv6_type_name_max;
+
+/* DUID type definitions (RFC3315 section 9).
+ */
+#define DUID_LLT	1
+#define DUID_EN		2
+#define DUID_LL		3
+
+/* Offsets into IA_*'s where Option spaces commence.  */
+#define IA_NA_OFFSET 12 /* IAID, T1, T2, all 4 octets each */
+#define IA_TA_OFFSET  4 /* IAID only, 4 octets */
+#define IA_PD_OFFSET 12 /* IAID, T1, T2, all 4 octets each */
+
+/* Offset into IAADDR's where Option spaces commence. */
+#define IAADDR_OFFSET 24
+
+/* Offset into IAPREFIX's where Option spaces commence. */
+#define IAPREFIX_OFFSET 25
+
+/* Offset into LQ_QUERY's where Option spaces commence. */
+#define LQ_QUERY_OFFSET 17
+
+/* 
+ * DHCPv6 well-known multicast addressess, from section 5.1 of RFC 3315 
+ */
+#define All_DHCP_Relay_Agents_and_Servers "FF02::1:2"
+#define All_DHCP_Servers "FF05::1:3"
+
+/*
+ * DHCPv6 Retransmission Constants (RFC3315 section 5.5, RFC 5007)
+ */
+
+#define SOL_MAX_DELAY     1
+#define SOL_TIMEOUT       1
+#define SOL_MAX_RT      120
+#define REQ_TIMEOUT       1
+#define REQ_MAX_RT       30
+#define REQ_MAX_RC       10
+#define CNF_MAX_DELAY     1
+#define CNF_TIMEOUT       1
+#define CNF_MAX_RT        4
+#define CNF_MAX_RD       10
+#define REN_TIMEOUT      10
+#define REN_MAX_RT      600
+#define REB_TIMEOUT      10
+#define REB_MAX_RT      600
+#define INF_MAX_DELAY     1
+#define INF_TIMEOUT       1
+#define INF_MAX_RT      120
+#define REL_TIMEOUT       1
+#define REL_MAX_RC        5
+#define DEC_TIMEOUT       1
+#define DEC_MAX_RC        5
+#define REC_TIMEOUT       2
+#define REC_MAX_RC        8
+#define HOP_COUNT_LIMIT  32
+#define LQ6_TIMEOUT       1
+#define LQ6_MAX_RT       10
+#define LQ6_MAX_RC        5
+
+/* 
+ * Normal packet format, defined in section 6 of RFC 3315 
+ */
+struct dhcpv6_packet {
+	unsigned char msg_type;
+	unsigned char transaction_id[3];
+	unsigned char options[FLEXIBLE_ARRAY_MEMBER];
+};
+
+/* Offset into DHCPV6 Reply packets where Options spaces commence. */
+#define REPLY_OPTIONS_INDEX 4
+
+/* 
+ * Relay packet format, defined in section 7 of RFC 3315 
+ */
+struct dhcpv6_relay_packet {
+	unsigned char msg_type;
+	unsigned char hop_count;
+	unsigned char link_address[16];
+	unsigned char peer_address[16];
+	unsigned char options[FLEXIBLE_ARRAY_MEMBER];
+};
+
+/* Leasequery query-types (RFC 5007) */
+
+#define LQ6QT_BY_ADDRESS	1
+#define LQ6QT_BY_CLIENTID	2
+
+/*
+ * DUID time starts 2000-01-01.
+ * This constant is the number of seconds since 1970-01-01,
+ * when the Unix epoch began.
+ */
+#define DUID_TIME_EPOCH 946684800
+
+/* Information-Request Time option (RFC 4242) */
+
+#define IRT_DEFAULT	86400
+#define IRT_MINIMUM	600
+

+ 14 - 0
src/bin/dhcp6/dhcp6.spec

@@ -0,0 +1,14 @@
+{
+  "module_spec": {
+    "module_name": "dhcp6",
+    "module_description": "DHCPv6 daemon",
+    "config_data": [
+      { "item_name": "interface",
+        "item_type": "string",
+        "item_optional": false,
+        "item_default": "eth0"
+      }
+    ],
+    "commands": []
+  }
+}

+ 122 - 0
src/bin/dhcp6/main.cc

@@ -0,0 +1,122 @@
+// Copyright (C) 2009-2011  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.
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/select.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <cassert>
+#include <iostream>
+
+#include <exceptions/exceptions.h>
+#include <cc/session.h>
+#include <config/ccsession.h>
+
+#include <util/buffer.h>
+#include <log/dummylog.h>
+
+#include <dhcp6/spec_config.h>
+
+
+using namespace std;
+using namespace isc::util;
+using namespace isc::data;
+using namespace isc::cc;
+using namespace isc::config;
+using namespace isc::util;
+
+namespace {
+
+bool verbose_mode = false;
+
+void
+usage() {
+    cerr << "Usage:  b10-dhcp6 [-u user] [-v]"
+         << endl;
+    cerr << "\t-u: change process UID to the specified user" << endl;
+    cerr << "\t-v: verbose output" << endl;
+    exit(1);
+}
+} // end of anonymous namespace
+
+int
+main(int argc, char* argv[]) {
+    int ch;
+    const char* uid = NULL;
+    bool cache = true;
+
+    while ((ch = getopt(argc, argv, ":nu:v")) != -1) {
+        switch (ch) {
+        case 'n':
+            cache = false;
+            break;
+        case 'u':
+            uid = optarg;
+            break;
+        case 'v':
+            verbose_mode = true;
+            isc::log::denabled = true;
+            break;
+        case '?':
+        default:
+            usage();
+        }
+    }
+
+    if (argc - optind > 0) {
+        usage();
+    }
+
+    int ret = 0;
+
+    // XXX: we should eventually pass io_service here.
+#if 0
+    Session* cc_session = NULL;
+    Session* xfrin_session = NULL;
+    Session* statistics_session = NULL;
+    bool xfrin_session_established = false; // XXX (see Trac #287)
+    bool statistics_session_established = false; // XXX (see Trac #287)
+    ModuleCCSession* config_session = NULL;
+#endif
+    try {
+        string specfile;
+        if (getenv("B10_FROM_BUILD")) {
+            specfile = string(getenv("B10_FROM_BUILD")) +
+                "/src/bin/auth/dhcp6.spec";
+        } else {
+            specfile = string(DHCP6_SPECFILE_LOCATION);
+        }
+
+        // auth_server = new AuthSrv(cache, xfrout_client);
+        // auth_server->setVerbose(verbose_mode);
+        cout << "[b10-dhcp6] Initiating DHCPv6 operation." << endl;
+
+    } catch (const std::exception& ex) {
+        cerr << "[b10-dhcp6] Server failed: " << ex.what() << endl;
+        ret = 1;
+    }
+
+    while (true) {
+            sleep(10);
+            cout << "[b10-dhcp6] I'm alive." << endl;
+    }
+
+    return (ret);
+}

+ 15 - 0
src/bin/dhcp6/spec_config.h.pre.in

@@ -0,0 +1,15 @@
+// Copyright (C) 2011  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.
+
+#define DHCP6_SPECFILE_LOCATION "@prefix@/share/@PACKAGE@/dhcp6.spec"

+ 22 - 0
src/bin/dhcp6/tests/Makefile.am

@@ -0,0 +1,22 @@
+PYCOVERAGE_RUN = @PYCOVERAGE_RUN@
+#PYTESTS = args_test.py bind10_test.py
+# NOTE: this has a generated test found in the builddir
+PYTESTS = dhcp6_test.py
+EXTRA_DIST = $(PYTESTS)
+
+# If necessary (rare cases), explicitly specify paths to dynamic libraries
+# required by loadable python modules.
+LIBRARY_PATH_PLACEHOLDER =
+if SET_ENV_LIBRARY_PATH
+LIBRARY_PATH_PLACEHOLDER += $(ENV_LIBRARY_PATH)=$(abs_top_builddir)/src/lib/cc/.libs:$(abs_top_builddir)/src/lib/config/.libs:$(abs_top_builddir)/src/lib/log/.libs:$(abs_top_builddir)/src/lib/util/.libs:$(abs_top_builddir)/src/lib/exceptions/.libs:$$$(ENV_LIBRARY_PATH)
+endif
+
+# test using command-line arguments, so use check-local target instead of TESTS
+check-local:
+	for pytest in $(PYTESTS) ; do \
+	echo Running test: $$pytest ; \
+	env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/bin/bind10 \
+	$(LIBRARY_PATH_PLACEHOLDER) \
+	BIND10_MSGQ_SOCKET_FILE=$(abs_top_builddir)/msgq_socket \
+		$(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest || exit ; \
+	done

+ 65 - 0
src/bin/dhcp6/tests/dhcp6_test.py

@@ -0,0 +1,65 @@
+# Copyright (C) 2011 Internet Systems Consortium.
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
+# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+from bind10 import ProcessInfo, parse_args, dump_pid, unlink_pid_file, _BASETIME
+
+import unittest
+import sys
+import os
+import signal
+import socket
+from isc.net.addr import IPAddr
+import time
+import isc
+
+class TestDhcpv6Daemon(unittest.TestCase):
+    def setUp(self):
+        # redirect stdout to a pipe so we can check that our
+        # process spawning is doing the right thing with stdout
+        self.old_stdout = os.dup(sys.stdout.fileno())
+        self.pipes = os.pipe()
+        os.dup2(self.pipes[1], sys.stdout.fileno())
+        os.close(self.pipes[1])
+        # note that we use dup2() to restore the original stdout
+        # to the main program ASAP in each test... this prevents
+        # hangs reading from the child process (as the pipe is only
+        # open in the child), and also insures nice pretty output
+
+    def tearDown(self):
+        # clean up our stdout munging
+        os.dup2(self.old_stdout, sys.stdout.fileno())
+        os.close(self.pipes[0])
+
+    def test_alive(self):
+        """
+        Simple test. Checks that b10-dhcp6 can be started and prints out info 
+        about starting DHCPv6 operation.
+        """
+        pi = ProcessInfo('Test Process', [ '../b10-dhcp6' , '-v' ])
+        pi.spawn()
+        time.sleep(1)
+        os.dup2(self.old_stdout, sys.stdout.fileno())
+        self.assertNotEqual(pi.process, None)
+        self.assertTrue(type(pi.pid) is int)
+        output = os.read(self.pipes[0], 4096)
+        self.assertEqual( str(output).count("[b10-dhcp6] Initiating DHCPv6 operation."), 1)
+
+        # kill this process
+        # XXX: b10-dhcp6 is too dumb to understand 'shutdown' command for now,
+        #      so let's just kill the bastard
+        os.kill(pi.pid, signal.SIGTERM)
+
+if __name__ == '__main__':
+    unittest.main()

+ 2 - 2
src/bin/resolver/resolver.cc

@@ -14,6 +14,7 @@
 
 #include <config.h>
 
+#include <stdint.h>
 #include <netinet/in.h>
 
 #include <algorithm>
@@ -21,7 +22,6 @@
 #include <cassert>
 
 #include <boost/shared_ptr.hpp>
-#include <boost/lexical_cast.hpp>
 #include <boost/foreach.hpp>
 
 #include <exceptions/exceptions.h>
@@ -57,7 +57,7 @@
 #include "resolver_log.h"
 
 using namespace std;
-using namespace boost;
+using boost::shared_ptr;
 
 using namespace isc;
 using namespace isc::util;

+ 1 - 0
src/bin/resolver/tests/Makefile.am

@@ -48,6 +48,7 @@ run_unittests_LDADD += $(top_builddir)/src/lib/cache/libcache.la
 run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
 run_unittests_LDADD += $(top_builddir)/src/lib/resolve/libresolve.la
 run_unittests_LDADD += $(top_builddir)/src/lib/acl/libacl.la
+run_unittests_LDADD += $(top_builddir)/src/lib/util/libutil.la
 run_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
 
 # Note the ordering matters: -Wno-... must follow -Wextra (defined in

+ 14 - 0
src/lib/acl/loader.h

@@ -59,7 +59,9 @@ public:
         BadValue(file, line, what),
         element_(element)
     {}
+
     ~ LoaderError() throw() {}
+
     /**
      * \brief Get the element.
      *
@@ -157,6 +159,7 @@ public:
         default_action_(defaultAction),
         action_loader_(actionLoader)
     {}
+
     /**
      * \brief Creator of the checks.
      *
@@ -168,6 +171,9 @@ public:
      */
     class CheckCreator {
     public:
+        /** \brief Virtual class needs virtual destructor */
+        virtual ~CheckCreator() {}
+
         /**
          * \brief List of names supported by this loader.
          *
@@ -177,6 +183,7 @@ public:
          * types of checks.
          */
         virtual std::vector<std::string> names() const = 0;
+
         /**
          * \brief Creates the check.
          *
@@ -200,6 +207,7 @@ public:
         virtual boost::shared_ptr<Check<Context> > create(
             const std::string& name, data::ConstElementPtr definition,
             const Loader<Context, Action>& loader) = 0;
+
         /**
          * \brief Is list or-abbreviation allowed?
          *
@@ -219,6 +227,7 @@ public:
             return (true);
         }
     };
+
     /**
      * \brief Register another check creator.
      *
@@ -252,6 +261,7 @@ public:
             creators_[*i] = creator;
         }
     }
+
     /**
      * \brief Load a check.
      *
@@ -282,6 +292,7 @@ public:
         // Call the internal part with extracted map
         return (loadCheck(description, map));
     }
+
     /**
      * \brief Load an ACL.
      *
@@ -332,6 +343,7 @@ public:
         }
         return (result);
     }
+
 private:
     // Some type aliases to save typing
     typedef std::map<std::string, boost::shared_ptr<CheckCreator> > Creators;
@@ -341,6 +353,7 @@ private:
     Creators creators_;
     const Action default_action_;
     const boost::function1<Action, data::ConstElementPtr> action_loader_;
+
     /**
      * \brief Internal version of loadCheck.
      *
@@ -412,6 +425,7 @@ private:
             }
         }
     }
+
     /**
      * \brief Check that always matches.
      *

+ 4 - 4
src/lib/log/Makefile.am

@@ -8,7 +8,7 @@ CLEANFILES = *.gcno *.gcda
 lib_LTLIBRARIES = liblog.la
 liblog_la_SOURCES  =
 liblog_la_SOURCES += dummylog.h dummylog.cc
-liblog_la_SOURCES += impldef.cc impldef.h
+liblog_la_SOURCES += logimpl_messages.cc logimpl_messages.h
 liblog_la_SOURCES += log_formatter.h log_formatter.cc
 liblog_la_SOURCES += logger.cc logger.h
 liblog_la_SOURCES += logger_impl.cc logger_impl.h
@@ -21,7 +21,7 @@ liblog_la_SOURCES += logger_name.cc logger_name.h
 liblog_la_SOURCES += logger_specification.h
 liblog_la_SOURCES += logger_support.cc logger_support.h
 liblog_la_SOURCES += macros.h
-liblog_la_SOURCES += messagedef.cc messagedef.h
+liblog_la_SOURCES += log_messages.cc log_messages.h
 liblog_la_SOURCES += message_dictionary.cc message_dictionary.h
 liblog_la_SOURCES += message_exception.h
 liblog_la_SOURCES += message_initializer.cc message_initializer.h
@@ -30,8 +30,8 @@ liblog_la_SOURCES += message_types.h
 liblog_la_SOURCES += output_option.cc output_option.h
 
 EXTRA_DIST  = README
-EXTRA_DIST += impldef.mes
-EXTRA_DIST += messagedef.mes
+EXTRA_DIST += logimpl_messages.mes
+EXTRA_DIST += log_messages.mes
 
 # Note: the ordering matters: -Wno-... must follow -Wextra (defined in
 # B10_CXXFLAGS)

+ 190 - 131
src/lib/log/README

@@ -1,11 +1,12 @@
 This directory holds the first release of the logging system.
 
+
 Basic Ideas
 ===========
 The BIND-10 logging system merges two ideas:
 
 * A hierarchical logging system similar to that used in Java (i.e. log4j)
-* Separation of message definitions and text
+* Separation of message use from message text
 
 
 Hierarchical Logging System
@@ -28,23 +29,26 @@ above, the INFO/Syslog attributes could be associated with the root logger
 while the DEBUG/file attributes are associated with the "cache" logger.
 
 
-Separation of Messages Definitions And Text
-===========================================
-The reason for this is to allow the message text to be overridden by versions
-in a local language.  To do this, each message is identified by an identifier
-e.g. "OPENIN".  Within the program, this is the symbol passed to the logging
-system.  The logger system uses the symbol as an index into a dictionary to
-retrieve the message associated with it (e.g. "unable to open %s for input").
-substitutes any message parameters (in this example, the string that is an
-invalid filename) and logs it to the destination.
+Separation of Messages Use from Message Text
+============================================
+By separating the use of the message from the text associated with this -
+in essence, defining message text in an external file - it is possible to
+replace the supplied text of the messages with a local language version.
 
-In the BIND-10 system, a set of default messages are linked into the
-program.  At run-time. each program reads a message file, updating the
-stored definitions; this updated text is logged.  However, to aid support,
-the message identifier so in the example above, the message finally logged
-would be something like:
+Each message is identified by an identifier e.g. "LOG_WRITE_ERROR".
+Within the program, this is the symbol passed to the logging system.
+The logger system uses the symbol as an index into a dictionary to
+retrieve the message associated with it (e.g. "unable to open %s for
+input").  It then substitutes any message parameters (in this example,
+the name of the file where the write operation failed) and logs it to
+the destination.
 
-    FAC_OPENIN, unable to open a.txt for input
+In BIND-10, a the default text for each message is linked into the
+program.  Each program is able to read a locally-defined message file
+when it starts, updating the stored definitions with site-specific text.
+When the message is logged, the updated text is output. However, the
+message identifier is always included in the output so that the origin
+of the message can be identified even if the text has been changed.
 
 
 Using The System
@@ -52,8 +56,9 @@ Using The System
 The steps in using the system are:
 
 1. Create a message file.  This defines messages by an identification - a
-   mnemonic for the message, typically 6-12 characters long - and a message.
-   The file is described in more detail below.
+   mnemonic for the message, the convention being that these are a few
+   words separated by underscores - and text that explains the message in
+   more detail.  The file is described in more detail below.
 
    Ideally the file should have a file type of ".mes".
 
@@ -73,9 +78,7 @@ The steps in using the system are:
    described in more detail below.
 
 5. To set the debug level and run-time message file, call initLogger (declared
-   in logger_support.h) in the main program unit.  This is a temporary solution
-   for Year 2, and will be replaced at a later date, the information coming
-   from the configuration database.
+   in logger_support.h) in the main program unit.
 
 
 Message Files
@@ -90,16 +93,16 @@ An example file could be:
 -- BEGIN --
 
 # Example message file
-# $ID:$
 
-$PREFIX TEST_
 $NAMESPACE isc::log
 
-% TEST1       message %1 is much too large
-This message is a test for the general message code
+% LOG_UNRECOGNISED_DIRECTIVE line %1: unrecognised directive '%2'
+A line starting with a dollar symbol was found, but the first word on the line
+(shown in the message) was not a recognised message compiler directive.
 
-% UNKNOWN     unknown message
-Issued when the message is unknown.
+% LOG_WRITE_ERROR error writing to %1: %2
+The specified error was encountered by the message compiler when writing to
+the named output file.
 
 -- END --
 
@@ -114,10 +117,8 @@ Points to note:
   a line by themselves - inline comments will be interpreted as part of the
   text of the line.
 
-* Lines starting $ are directives.  At present, two directives are recognised:
-
-  * $PREFIX, which has one optional argument: the string used to prefix symbols.
-    If absent, there is no prefix to the symbols (prefixes are explained below).
+* Lines starting $ are directives.  At present, just one directive is
+  recognised:
 
   * $NAMESPACE, which has one argument: the namespace in which the symbols are
     created.  In the absence of a $NAMESPACE directive, symbols will be put in
@@ -127,10 +128,19 @@ Points to note:
   identification and the message text, the latter including zero or more
   replacement tokens, e.g.
 
-     % TEST  message %1 is larger than the permitted length of %2
+     % LOG_WRITE_ERROR error writing to %1: %2
 
   * There may be zero or more spaces between the leading "%" and the message
-    identification (which, in the example above, is the word "TEST").
+    identification (which, in the example above, is the string
+    "LOG_WRITE_ERROR").
+
+  * The message identification can be any string of letters, digits and
+    underscores, but should not start with a digit.  The convention adopted
+    in BIND 10 is for the first component (before the first underscore) to be
+    a string indicating the origin of the message, and the remainder to
+    describe the message.  So in the example above, the LOG_ indicates that
+    the error originated from the logging library and the "WRITE_ERROR"
+    indicates that there was a problem in a write operation.
 
   * The replacement tokens are the strings "%1", "%2" etc.  When a message
     is logged, these are replaced with the arguments passed to the logging
@@ -147,42 +157,36 @@ Message Compiler
 The message compiler is a program built in the src/log/compiler directory.
 It is invoked by the command:
 
-    message [-h] [-v] <message-file>
+    message [-h] [-v] -p] <message-file>
+
+("-v" prints the version number and exits; "-h" prints brief help text.)  The
+compiler produces source files for C++ and Python.
 
-("-v" prints the version number and exits; "-h" prints brief help text.)
-The message compiler processes the message file to produce two files:
+C++ Files
+---------
+Without the "-p" option, the message compiler processes the message file
+to produce two files:
 
 1) A C++ header file (called <message-file-name>.h) that holds lines of
 the form:
 
    namespace <namespace> {
-   extern const isc::log::MessageID PREFIX_IDENTIFIER;
+   extern const isc::log::MessageID LOG_WRITE_ERROR;
       :
    }
 
 The symbols define the keys in the global message dictionary, with the
 namespace enclosing the symbols set by the $NAMESPACE directive.
 
-The "PREFIX_" part of the symbol name is the string defined in the $PREFIX
-the argument to the directive.  So "$PREFIX MSG_" would prefix the identifier
-ABC with "MSG_" to give the symbol MSG_ABC.  Similarly "$PREFIX E" would
-prefix it with "E" to give the symbol EABC.  If no $PREFIX is given, no
-prefix appears (so the symbol in this example would be ABC).
-
-The prefix is "syntactic sugar".  Generally all symbols in a given message file
-will be prefixed with the same set of letters.  By extracting these into
-a separate prefix, it becomes easier to disambiguate the different symbols.
-
-There may be multiple $PREFIX directives in a file.  A $PREFIX directive applies
-to all message definitions between it an the next $PREFIX directive.  A $PREFIX
-directive with no arguments clears the current prefix.
+(This is the reason for the restriction on message identifiers - they
+have to be valid C++ symbol names.)
 
 2) A C++ source file (called <message-file-name>.cc) that holds the definitions
 of the global symbols and code to insert the symbols and messages into the map.
 
 Symbols are defined to be equal to strings holding the identifier, e.g.
 
-   extern const isc::log::MessageID MSG_DUPLNS = "MSG_DUPLNS";
+   extern const isc::log::MessageID LOG_WRITE_ERROR = "LOG_WRITE_ERROR";
 
 (The implementation allows symbols to be compared.  However, use of strings
 should not be assumed - a future implementation may change this.)
@@ -208,16 +212,29 @@ A check is made as each is added; if the identifier already exists, it is
 added to "overflow" vector; the vector is printed to the main logging output
 when logging is finally enabled (to indicate a programming error).
 
+Python Files
+------------
+If the "-p" option is given, the compiler produces a Python module defining
+the messages.  The format of this is:
+
+import isc.log
+    :
+LOG_WRITE_ERROR = isc.log.create_message("LOG_WRITE_ERROR",
+        "error writing to %1 : %2")
 
-Using the Logging
-=================
-To use the current version of the logging:
+(The definition is output on one line - it is split across two lines in this
+document for readability.)
 
+The module can be imported into other Python code, and messages logged
+in a similar way to C++ using the Python logging library.
+
+Using the Logging - C++
+=======================
 1. Build message header file and source file as describe above.
 
 2. The main program unit should include a call to isc::log::initLogger()
-   (defined in logger_support.h) to set the logging severity, debug log level,
-   and external message file:
+   (defined in logger_support.h) to set the logging severity, debug log
+   level, and external message file:
 
    a) The logging severity is one of the enum defined in logger.h, i.e.
 
@@ -228,88 +245,134 @@ To use the current version of the logging:
         isc::log::FATAL
         isc::log::NONE
 
-   b) The debug log level is only interpreted when the severity is DEBUG and
-      is an integer ranging from 0 to 99.  0 should be used for the
-      highest-level debug messages and 99 for the lowest-level (and typically
-      more verbose) messages.
+   b) The debug log level is only interpreted when the severity is
+      DEBUG and is an integer ranging from 0 to 99.  0 should be used
+      for the highest-level debug messages and 99 for the lowest-level
+      (and typically more verbose) messages.
+
+   c) The external message file.  If present, this is the same as a
+      standard message file, although it should not include any
+      directives. (A single directive of a particular type will be
+      ignored; multiple directives will cause the read of the file to
+      fail with an error.)
+
+   The settings remain in effect until the logging configuration is read,
+   and so provide the default logging during program initialization.
+
+3. Declare a logger through which the message will be logged.
+
+       isc::log::Logger logger("name");
+
+   The string passed to the constructor is the name of the logger (it
+   can be any string) and is used when configuring it.  Loggers with
+   the same name share the same configuration.
 
-   c) The external message file.  If present, this is the same as a standard
-      message file, although it should not include any directives. (A single
-      directive of a particular type will be ignored; multiple directives will
-      cause the read of the file to fail with an error.)
+4. Issue logging calls using supplied macros in "log/macros.h", e.g.
 
-   The settings remain in effect until the logging configuration is read, and
-   so provide the default logging during program initialization.
+       LOG_ERROR(logger, LOG_WRITE_ERROR).arg("output.txt");
 
-3. Issue logging calls using supplied macros in "log/macros.h", e.g.
+   (The macros are more efficient that calls to the methods on the logger
+   class: they avoid the overhead of evaluating the parameters to arg()
+   if the settings are such that the message is not going to be output.)
 
-       LOG_ERROR(logger, DPS_NSTIMEOUT).arg("isc.org");
+Using the Logging - Python
+==========================
+1. Build message module as describe above.
 
-   (The macros are more efficient that calls to the methods on the logger class:
-   they avoid the overhead of evaluating the parameters to arg() if the
-   settings are such that the message is not going to be output.)
+2. The main program unit should include a call to isc.log.init() to
+   set the to set the logging severity, debug log level, and external
+   message file:
 
-   Note: in the example above we might have defined the symbol in the message
-   file with something along the lines of:
+   a) The logging severity is one of the strings:
+
+        DEBUG
+        INFO
+        WARN
+        ERROR
+        FATAL
+        NONE
+
+   b) The debug log level is only interpreted when the severity is
+      DEBUG and is an integer ranging from 0 to 99.  0 should be used
+      for the highest-level debug messages and 99 for the lowest-level
+      (and typically more verbose) messages.
+
+   c) The external message file.  If present, this is the same as a
+      standard message file, although it should not include any
+      directives. (Any that are there will be ignored.)
+
+   The settings remain in effect until the logging configuration is read,
+   and so provide the default logging during program initialization.
+
+3. Declare a logger through which the message will be logged.
+
+       isc.log.Logger logger("name")
+
+   The string passed to the constructor is the name of the logger (it
+   can be any string) and is used when configuring it.  Loggers with
+   the same name share the same configuration.
+
+4. Issue calls to the logging methods:
+
+       logger.error(LOG_WRITE_ERROR, "output.txt");
 
-       $PREFIX DPS_
-           :
-       NSTIMEOUT  queries to all nameservers for %1 have timed out
 
 Severity Guidelines
 ===================
-When using logging, the question arises, what severity should a message be
-logged at?  The following is a suggestion - as always, the decision must be
-made in the context of which the message is logged.
+When using logging, the question arises, what severity should a message
+be logged at?  The following is a suggestion - as always, the decision
+must be made in the context of which the message is logged.
 
-One thing that should always be borne in mind is whether the logging could
-be used as a vector for a DOS attack.  For example, if a warning message is
-logged every time an invalid packet is received, an attacker could simply send
-large numbers of invalid packets.  (Of course, warnings could be disabled (or
-just warnings for that that particular logger), but nevertheless the message
-is an attack vector.)
+One thing that should always be borne in mind is whether the logging
+could be used as a vector for a DOS attack.  For example, if a warning
+message is logged every time an invalid packet is received, an attacker
+could simply send large numbers of invalid packets.  (Of course, warnings
+could be disabled (or just warnings for that that particular logger),
+but nevertheless the message is an attack vector.)
 
 FATAL
 -----
-The program has encountered an error that is so severe that it cannot continue
-(or there is no point in continuing).  When a fatal error has been logged,
-the program will usually exit immediately (or shortly afterwards) after
-dumping some diagnostic information.
+The program has encountered an error that is so severe that it cannot
+continue (or there is no point in continuing).  When a fatal error
+has been logged, the program will usually exit immediately (or shortly
+afterwards) after dumping some diagnostic information.
 
 ERROR
 -----
-Something has happened such that the program can continue but the results
-for the current (or future) operations cannot be guaranteed to be correct,
-or the results will be correct but the service is impaired.  For example,
-the program started but attempts to open one or more network interfaces failed.
+Something has happened such that the program can continue but the
+results for the current (or future) operations cannot be guaranteed to
+be correct, or the results will be correct but the service is impaired.
+For example, the program started but attempts to open one or more network
+interfaces failed.
 
 WARN
 ----
 An unusual event  happened.  Although the program will continue working
-normally, the event was sufficiently out of the ordinary to warrant drawing
-attention to it.  For example, at program start-up a zone was loaded that
-contained no resource records,
+normally, the event was sufficiently out of the ordinary to warrant
+drawing attention to it.  For example, at program start-up a zone was
+loaded that contained no resource records,
 
 INFO
 ----
 A normal but significant event has occurred that should be recorded,
-e.g. the program has started or is just about to terminate, a new zone has
-been created, etc.
+e.g. the program has started or is just about to terminate, a new zone
+has been created, etc.
 
 DEBUG
 -----
 This severity is only enabled on for debugging purposes.  A debug level is
 associated with debug messages, level 0 (the default) being for high-level
-messages and level 99 (the maximum) for the lowest level.  How the messages
-are distributed between the levels is up to the developer.  So if debugging
-the NSAS (for example), a level 0 message might record the creation of a new
-zone, a level 10 recording a timeout when trying to get a nameserver address,
-but a level 50 would record every query for an address. (And we might add
-level 70 to record every update of the RTT.)
-
-Note that like severities, levels are cumulative; so if level 25 is set as the
-debug level, all debug levels from 0 to 25 will be output.  In fact, it is
-probably easier to visualise the debug levels as part of the severity system:
+messages and level 99 (the maximum) for the lowest level.  How the
+messages are distributed between the levels is up to the developer.
+So if debugging the NSAS (for example), a level 0 message might record
+the creation of a new zone, a level 10 recording a timeout when trying
+to get a nameserver address, but a level 50 would record every query for
+an address. (And we might add level 70 to record every update of the RTT.)
+
+Note that like severities, levels are cumulative; so if level 25 is
+set as the debug level, all debug levels from 0 to 25 will be output.
+In fact, it is probably easier to visualise the debug levels as part of
+the severity system:
 
     FATAL                High
     ERROR
@@ -325,38 +388,34 @@ levels above it - will be logged.
 
 Logging Sources v Logging Severities
 ------------------------------------
-When logging events, make a distinction between events related to the server
-and events related to DNS messages received.  Caution needs to be exercised
-with the latter as, if the logging is enabled in the normal course of events,
-such logging could be a denial of service vector. For example, suppose that
-the main authoritative service logger were to log both zone loading and
-unloading as INFO and a warning message if it received an invalid packet. An
-attacker could make the INFO messages unusable by flooding the server with
-malformed packets.
+When logging events, make a distinction between events related to the
+server and events related to DNS messages received.  Caution needs to
+be exercised with the latter as, if the logging is enabled in the normal
+course of events, such logging could be a denial of service vector. For
+example, suppose that the main authoritative service logger were to
+log both zone loading and unloading as INFO and a warning message if
+it received an invalid packet. An attacker could make the INFO messages
+unusable by flooding the server with malformed packets.
 
 There are two approaches to get round this:
 
 a) Make the logging of packet-dependent events a DEBUG-severity message.
-DEBUG is not enabled by default, so these events will not be recorded unless
-DEBUG is specifically chosen.
+DEBUG is not enabled by default, so these events will not be recorded
+unless DEBUG is specifically chosen.
 
 b) Record system-related and packet-related messages via different loggers
-(e.g.  in the example given, server events could be logged using the logger
-"auth" and packet-related events at that level logged using the logger
-"pkt-auth".)  As the loggers are independent and the severity levels
-independent, fine-tuning of what and what is not recorded can be achieved.
+(e.g.  in the example given, server events could be logged using the
+logger "auth" and packet-related events at that level logged using the
+logger "pkt-auth".)  As the loggers are independent and the severity
+levels independent, fine-tuning of what and what is not recorded can
+be achieved.
 
 
 Notes
 =====
 The message compiler is written in C++ (instead of Python) because it
 contains a component that reads the message file.  This component is used
-in both the message compiler and the server; in the server it is used when
-the server starts up (or when triggered by a command) to read in a message
-file to overwrite the internal dictionary.  Writing it in C++ means there
-is only one piece of code that does this functionality.
-
-
-Outstanding Issues
-==================
-* Ability to configure system according to configuration database.
+in both the message compiler and the server; in the server it is used
+when the server starts up (or when triggered by a command) to read in
+a message file to overwrite the internal dictionary.  Writing it in C++
+means there is only one piece of code that does this functionality.

+ 5 - 5
src/lib/log/compiler/message.cc

@@ -28,10 +28,10 @@
 #include <util/filename.h>
 #include <util/strutil.h>
 
+#include <log/log_messages.h>
 #include <log/message_dictionary.h>
 #include <log/message_exception.h>
 #include <log/message_reader.h>
-#include <log/messagedef.h>
 
 #include <log/logger.h>
 
@@ -306,7 +306,7 @@ writeHeaderFile(const string& file, const vector<string>& ns_components,
     ofstream hfile(header_file.fullName().c_str());
 
     if (hfile.fail()) {
-        throw MessageException(MSG_OPENOUT, header_file.fullName(),
+        throw MessageException(LOG_OPEN_OUTPUT_FAIL, header_file.fullName(),
             strerror(errno));
     }
 
@@ -340,7 +340,7 @@ writeHeaderFile(const string& file, const vector<string>& ns_components,
 
     // Report errors (if any) and exit
     if (hfile.fail()) {
-        throw MessageException(MSG_WRITERR, header_file.fullName(),
+        throw MessageException(LOG_WRITE_ERROR, header_file.fullName(),
             strerror(errno));
     }
 
@@ -394,7 +394,7 @@ writeProgramFile(const string& file, const vector<string>& ns_components,
     ofstream ccfile(program_file.fullName().c_str());
 
     if (ccfile.fail()) {
-        throw MessageException(MSG_OPENOUT, program_file.fullName(),
+        throw MessageException(LOG_OPEN_OUTPUT_FAIL, program_file.fullName(),
             strerror(errno));
     }
 
@@ -452,7 +452,7 @@ writeProgramFile(const string& file, const vector<string>& ns_components,
 
     // Report errors (if any) and exit
     if (ccfile.fail()) {
-        throw MessageException(MSG_WRITERR, program_file.fullName(),
+        throw MessageException(LOG_WRITE_ERROR, program_file.fullName(),
             strerror(errno));
     }
 

+ 0 - 29
src/lib/log/impldef.cc

@@ -1,29 +0,0 @@
-// File created from impldef.mes on Wed Jun  1 10:32:57 2011
-
-#include <cstddef>
-#include <log/message_types.h>
-#include <log/message_initializer.h>
-
-namespace isc {
-namespace log {
-
-extern const isc::log::MessageID LOGIMPL_ABOVEDBGMAX = "LOGIMPL_ABOVEDBGMAX";
-extern const isc::log::MessageID LOGIMPL_BADDEBUG = "LOGIMPL_BADDEBUG";
-extern const isc::log::MessageID LOGIMPL_BELOWDBGMIN = "LOGIMPL_BELOWDBGMIN";
-
-} // namespace log
-} // namespace isc
-
-namespace {
-
-const char* values[] = {
-    "LOGIMPL_ABOVEDBGMAX", "debug level of %1 is too high and will be set to the maximum of %2",
-    "LOGIMPL_BADDEBUG", "debug string is '%1': must be of the form DEBUGn",
-    "LOGIMPL_BELOWDBGMIN", "debug level of %1 is too low and will be set to the minimum of %2",
-    NULL
-};
-
-const isc::log::MessageInitializer initializer(values);
-
-} // Anonymous namespace
-

+ 0 - 18
src/lib/log/impldef.h

@@ -1,18 +0,0 @@
-// File created from impldef.mes on Wed Jun  1 10:32:57 2011
-
-#ifndef __IMPLDEF_H
-#define __IMPLDEF_H
-
-#include <log/message_types.h>
-
-namespace isc {
-namespace log {
-
-extern const isc::log::MessageID LOGIMPL_ABOVEDBGMAX;
-extern const isc::log::MessageID LOGIMPL_BADDEBUG;
-extern const isc::log::MessageID LOGIMPL_BELOWDBGMIN;
-
-} // namespace log
-} // namespace isc
-
-#endif // __IMPLDEF_H

+ 0 - 38
src/lib/log/impldef.mes

@@ -1,38 +0,0 @@
-# Copyright (C) 2011  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.
-
-# \brief Logger Implementation Messages
-#
-# This holds messages generated by the underlying logger implementation.  They
-# are likely to be specific to that implementation, and may well change if the
-# underlying implementation is changed.  For that reason, they have been put
-# in a separate file.
-
-$PREFIX LOGIMPL_
-$NAMESPACE isc::log
-
-% ABOVEDBGMAX   debug level of %1 is too high and will be set to the maximum of %2
-A message from the underlying logger implementation code, the debug level
-(as set by the string DEBGUGn) is above the maximum allowed value and has
-been reduced to that value.
-
-% BADDEBUG      debug string is '%1': must be of the form DEBUGn
-The string indicating the extended logging level (used by the underlying
-logger implementation code) is not of the stated form.  In particular,
-it starts DEBUG but does not end with an integer.
-
-% BELOWDBGMIN   debug level of %1 is too low and will be set to the minimum of %2
-A message from the underlying logger implementation code, the debug level
-(as set by the string DEBGUGn) is below the minimum allowed value and has
-been increased to that value.

+ 63 - 0
src/lib/log/log_messages.cc

@@ -0,0 +1,63 @@
+// File created from log_messages.mes on Wed Jun 22 11:54:57 2011
+
+#include <cstddef>
+#include <log/message_types.h>
+#include <log/message_initializer.h>
+
+namespace isc {
+namespace log {
+
+extern const isc::log::MessageID LOG_BAD_DESTINATION = "LOG_BAD_DESTINATION";
+extern const isc::log::MessageID LOG_BAD_SEVERITY = "LOG_BAD_SEVERITY";
+extern const isc::log::MessageID LOG_BAD_STREAM = "LOG_BAD_STREAM";
+extern const isc::log::MessageID LOG_DUPLICATE_MESSAGE_ID = "LOG_DUPLICATE_MESSAGE_ID";
+extern const isc::log::MessageID LOG_DUPLICATE_NAMESPACE = "LOG_DUPLICATE_NAMESPACE";
+extern const isc::log::MessageID LOG_INPUT_OPEN_FAIL = "LOG_INPUT_OPEN_FAIL";
+extern const isc::log::MessageID LOG_INVALID_MESSAGE_ID = "LOG_INVALID_MESSAGE_ID";
+extern const isc::log::MessageID LOG_NAMESPACE_EXTRA_ARGS = "LOG_NAMESPACE_EXTRA_ARGS";
+extern const isc::log::MessageID LOG_NAMESPACE_INVALID_ARG = "LOG_NAMESPACE_INVALID_ARG";
+extern const isc::log::MessageID LOG_NAMESPACE_NO_ARGS = "LOG_NAMESPACE_NO_ARGS";
+extern const isc::log::MessageID LOG_NO_MESSAGE_ID = "LOG_NO_MESSAGE_ID";
+extern const isc::log::MessageID LOG_NO_MESSAGE_TEXT = "LOG_NO_MESSAGE_TEXT";
+extern const isc::log::MessageID LOG_NO_SUCH_MESSAGE = "LOG_NO_SUCH_MESSAGE";
+extern const isc::log::MessageID LOG_OPEN_OUTPUT_FAIL = "LOG_OPEN_OUTPUT_FAIL";
+extern const isc::log::MessageID LOG_PREFIX_EXTRA_ARGS = "LOG_PREFIX_EXTRA_ARGS";
+extern const isc::log::MessageID LOG_PREFIX_INVALID_ARG = "LOG_PREFIX_INVALID_ARG";
+extern const isc::log::MessageID LOG_READING_LOCAL_FILE = "LOG_READING_LOCAL_FILE";
+extern const isc::log::MessageID LOG_READ_ERROR = "LOG_READ_ERROR";
+extern const isc::log::MessageID LOG_UNRECOGNISED_DIRECTIVE = "LOG_UNRECOGNISED_DIRECTIVE";
+extern const isc::log::MessageID LOG_WRITE_ERROR = "LOG_WRITE_ERROR";
+
+} // namespace log
+} // namespace isc
+
+namespace {
+
+const char* values[] = {
+    "LOG_BAD_DESTINATION", "unrecognized log destination: %1",
+    "LOG_BAD_SEVERITY", "unrecognized log severity: %1",
+    "LOG_BAD_STREAM", "bad log console output stream: %1",
+    "LOG_DUPLICATE_MESSAGE_ID", "duplicate message ID (%1) in compiled code",
+    "LOG_DUPLICATE_NAMESPACE", "line %1: duplicate $NAMESPACE directive found",
+    "LOG_INPUT_OPEN_FAIL", "unable to open message file %1 for input: %2",
+    "LOG_INVALID_MESSAGE_ID", "line %1: invalid message identification '%2'",
+    "LOG_NAMESPACE_EXTRA_ARGS", "line %1: $NAMESPACE directive has too many arguments",
+    "LOG_NAMESPACE_INVALID_ARG", "line %1: $NAMESPACE directive has an invalid argument ('%2')",
+    "LOG_NAMESPACE_NO_ARGS", "line %1: no arguments were given to the $NAMESPACE directive",
+    "LOG_NO_MESSAGE_ID", "line %1: message definition line found without a message ID",
+    "LOG_NO_MESSAGE_TEXT", "line %1: line found containing a message ID ('%2') and no text",
+    "LOG_NO_SUCH_MESSAGE", "could not replace message text for '%1': no such message",
+    "LOG_OPEN_OUTPUT_FAIL", "unable to open %1 for output: %2",
+    "LOG_PREFIX_EXTRA_ARGS", "line %1: $PREFIX directive has too many arguments",
+    "LOG_PREFIX_INVALID_ARG", "line %1: $PREFIX directive has an invalid argument ('%2')",
+    "LOG_READING_LOCAL_FILE", "reading local message file %1",
+    "LOG_READ_ERROR", "error reading from message file %1: %2",
+    "LOG_UNRECOGNISED_DIRECTIVE", "line %1: unrecognised directive '%2'",
+    "LOG_WRITE_ERROR", "error writing to %1: %2",
+    NULL
+};
+
+const isc::log::MessageInitializer initializer(values);
+
+} // Anonymous namespace
+

+ 35 - 0
src/lib/log/log_messages.h

@@ -0,0 +1,35 @@
+// File created from log_messages.mes on Wed Jun 22 11:54:57 2011
+
+#ifndef __LOG_MESSAGES_H
+#define __LOG_MESSAGES_H
+
+#include <log/message_types.h>
+
+namespace isc {
+namespace log {
+
+extern const isc::log::MessageID LOG_BAD_DESTINATION;
+extern const isc::log::MessageID LOG_BAD_SEVERITY;
+extern const isc::log::MessageID LOG_BAD_STREAM;
+extern const isc::log::MessageID LOG_DUPLICATE_MESSAGE_ID;
+extern const isc::log::MessageID LOG_DUPLICATE_NAMESPACE;
+extern const isc::log::MessageID LOG_INPUT_OPEN_FAIL;
+extern const isc::log::MessageID LOG_INVALID_MESSAGE_ID;
+extern const isc::log::MessageID LOG_NAMESPACE_EXTRA_ARGS;
+extern const isc::log::MessageID LOG_NAMESPACE_INVALID_ARG;
+extern const isc::log::MessageID LOG_NAMESPACE_NO_ARGS;
+extern const isc::log::MessageID LOG_NO_MESSAGE_ID;
+extern const isc::log::MessageID LOG_NO_MESSAGE_TEXT;
+extern const isc::log::MessageID LOG_NO_SUCH_MESSAGE;
+extern const isc::log::MessageID LOG_OPEN_OUTPUT_FAIL;
+extern const isc::log::MessageID LOG_PREFIX_EXTRA_ARGS;
+extern const isc::log::MessageID LOG_PREFIX_INVALID_ARG;
+extern const isc::log::MessageID LOG_READING_LOCAL_FILE;
+extern const isc::log::MessageID LOG_READ_ERROR;
+extern const isc::log::MessageID LOG_UNRECOGNISED_DIRECTIVE;
+extern const isc::log::MessageID LOG_WRITE_ERROR;
+
+} // namespace log
+} // namespace isc
+
+#endif // __LOG_MESSAGES_H

+ 146 - 0
src/lib/log/log_messages.mes

@@ -0,0 +1,146 @@
+# Copyright (C) 2011  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.
+
+# \brief Message Utility Message File
+#
+# This is the source of the set of messages generated by the message and
+# logging components.  The associated .h and .cc files are created by hand from
+# this file though and are not built during the build process; this is to avoid
+# the chicken-and-egg situation where we need the files to build the message
+# compiler, yet we need the compiler to build the files.
+
+$NAMESPACE isc::log
+
+% LOG_BAD_DESTINATION unrecognized log destination: %1
+A logger destination value was given that was not recognized. The
+destination should be one of "console", "file", or "syslog".
+
+% LOG_BAD_SEVERITY unrecognized log severity: %1
+A logger severity value was given that was not recognized. The severity
+should be one of "DEBUG", "INFO", "WARN", "ERROR", or "FATAL".
+
+% LOG_BAD_STREAM bad log console output stream: %1
+A log console output stream was given that was not recognized. The output
+stream should be one of "stdout", or "stderr"
+
+% LOG_DUPLICATE_MESSAGE_ID duplicate message ID (%1) in compiled code
+During start-up, BIND10 detected that the given message identification had
+been defined multiple times in the BIND10 code.
+
+This has no ill-effects other than the possibility that an erronous
+message may be logged.  However, as it is indicative of a programming
+error, please log a bug report.
+
+% LOG_DUPLICATE_NAMESPACE line %1: duplicate $NAMESPACE directive found
+When reading a message file, more than one $NAMESPACE directive was found.
+Such a condition is regarded as an error and the read will be abandoned.
+
+% LOG_INPUT_OPEN_FAIL unable to open message file %1 for input: %2
+The program was not able to open the specified input message file for
+the reason given.
+
+% LOG_INVALID_MESSAGE_ID line %1: invalid message identification '%2'
+An invalid message identification (ID) has been found during the read of
+a message file.  Message IDs should comprise only alphanumeric characters
+and the underscore, and should not start with a digit.
+
+% LOG_NAMESPACE_EXTRA_ARGS line %1: $NAMESPACE directive has too many arguments
+The $NAMESPACE directive in a message file takes a single argument, a
+namespace in which all the generated symbol names are placed.  This error
+is generated when the compiler finds a $NAMESPACE directive with more
+than one argument.
+
+% LOG_NAMESPACE_INVALID_ARG line %1: $NAMESPACE directive has an invalid argument ('%2')
+The $NAMESPACE argument in a message file should be a valid C++ namespace.
+This message is output if the simple check on the syntax of the string
+carried out by the reader fails.
+
+% LOG_NAMESPACE_NO_ARGS line %1: no arguments were given to the $NAMESPACE directive
+The $NAMESPACE directive in a message file takes a single argument,
+a C++ namespace in which all the generated symbol names are placed.
+This error is generated when the compiler finds a $NAMESPACE directive
+with no arguments.
+
+% LOG_NO_MESSAGE_ID line %1: message definition line found without a message ID
+Within a message file, message are defined by lines starting with a "%".
+The rest of the line should comprise the message ID and text describing
+the message.  This error indicates the message compiler found a line in
+the message file comprising just the "%" and nothing else.
+
+% LOG_NO_MESSAGE_TEXT line %1: line found containing a message ID ('%2') and no text
+Within a message file, message are defined by lines starting with a "%".
+The rest of the line should comprise the message ID and text describing
+the message.  This error indicates the message compiler found a line
+in the message file comprising just the "%" and message identification,
+but no text.
+
+% LOG_NO_SUCH_MESSAGE could not replace message text for '%1': no such message
+During start-up a local message file was read.  A line with the listed
+message identification was found in the file, but the identification is
+not one contained in the compiled-in message dictionary.  This message
+may appear a number of times in the file, once for every such unknown
+message identification.
+
+There may be several reasons why this message may appear:
+
+- The message ID has been mis-spelled in the local message file.
+
+- The program outputting the message may not use that particular message
+(e.g. it originates in a module not used by the program.)
+
+- The local file was written for an earlier version of the BIND10 software
+and the later version no longer generates that message.
+
+Whatever the reason, there is no impact on the operation of BIND10.
+
+% LOG_OPEN_OUTPUT_FAIL unable to open %1 for output: %2
+Originating within the logging code, the program was not able to open
+the specified output file for the reason given.
+
+% LOG_PREFIX_EXTRA_ARGS line %1: $PREFIX directive has too many arguments
+Within a message file, the $PREFIX directive takes a single argument,
+a prefix to be added to the symbol names when a C++ file is created.
+This error is generated when the compiler finds a $PREFIX directive with
+more than one argument.
+
+Note: the $PREFIX directive is deprecated and will be removed in a future
+version of BIND10.
+
+% LOG_PREFIX_INVALID_ARG line %1: $PREFIX directive has an invalid argument ('%2')
+Within a message file, the $PREFIX directive takes a single argument,
+a prefix to be added to the symbol names when a C++ file is created.
+As such, it must adhere to restrictions on C++ symbol names (e.g. may
+only contain alphanumeric characters or underscores, and may nor start
+with a digit).  A $PREFIX directive was found with an argument (given
+in the message) that violates those restictions.
+
+Note: the $PREFIX directive is deprecated and will be removed in a future
+version of BIND10.
+
+% LOG_READING_LOCAL_FILE reading local message file %1
+This is an informational message output by BIND10 when it starts to read
+a local message file.  (A local message file may replace the text of
+one of more messages; the ID of the message will not be changed though.)
+
+% LOG_READ_ERROR error reading from message file %1: %2
+The specified error was encountered reading from the named message file.
+
+% LOG_UNRECOGNISED_DIRECTIVE line %1: unrecognised directive '%2'
+Within a message file, a line starting with a dollar symbol was found
+(indicating the presence of a directive) but the first word on the line
+(shown in the message) was not recognised.
+
+% LOG_WRITE_ERROR error writing to %1: %2
+The specified error was encountered by the message compiler when writing
+to the named output file.

+ 2 - 2
src/lib/log/logger_level.cc

@@ -14,7 +14,7 @@
 
 #include <log/logger_level.h>
 #include <log/macros.h>
-#include <log/messagedef.h>
+#include <log/log_messages.h>
 
 #include <boost/algorithm/string.hpp>
 
@@ -38,7 +38,7 @@ getSeverity(const std::string& sev_str) {
         return isc::log::NONE;
     } else {
         Logger logger("log");
-        LOG_ERROR(logger, MSG_BADSEVERITY).arg(sev_str);
+        LOG_ERROR(logger, LOG_BAD_SEVERITY).arg(sev_str);
         return isc::log::INFO;
     }
 }

+ 4 - 4
src/lib/log/logger_level_impl.cc

@@ -19,9 +19,9 @@
 
 #include <log4cplus/logger.h>
 
-#include <log/impldef.h>
 #include <log/logger_level.h>
 #include <log/logger_level_impl.h>
+#include <log/logimpl_messages.h>
 #include <log/macros.h>
 
 using namespace log4cplus;
@@ -157,12 +157,12 @@ LoggerLevelImpl::logLevelFromString(const log4cplus::tstring& level) {
                 try {
                     int dbglevel = boost::lexical_cast<int>(name.substr(5));
                     if (dbglevel < MIN_DEBUG_LEVEL) {
-                        LOG_WARN(logger, LOGIMPL_BELOWDBGMIN).arg(dbglevel)
+                        LOG_WARN(logger, LOGIMPL_BELOW_MIN_DEBUG).arg(dbglevel)
                             .arg(MIN_DEBUG_LEVEL);
                         dbglevel = MIN_DEBUG_LEVEL;
 
                     } else if (dbglevel > MAX_DEBUG_LEVEL) {
-                        LOG_WARN(logger, LOGIMPL_ABOVEDBGMAX).arg(dbglevel)
+                        LOG_WARN(logger, LOGIMPL_ABOVE_MAX_DEBUG).arg(dbglevel)
                             .arg(MAX_DEBUG_LEVEL);
                         dbglevel = MAX_DEBUG_LEVEL;
 
@@ -170,7 +170,7 @@ LoggerLevelImpl::logLevelFromString(const log4cplus::tstring& level) {
                     return convertFromBindLevel(Level(DEBUG, dbglevel));
                 }
                 catch (boost::bad_lexical_cast&) {
-                    LOG_ERROR(logger, LOGIMPL_BADDEBUG).arg(name);
+                    LOG_ERROR(logger, LOGIMPL_BAD_DEBUG_STRING).arg(name);
                     return (NOT_SET_LOG_LEVEL);
                 }
             }

+ 8 - 9
src/lib/log/logger_manager.cc

@@ -15,20 +15,19 @@
 #include <algorithm>
 #include <vector>
 
-#include <log/logger_level.h>
-#include <log/logger_manager_impl.h>
+#include <log/logger.h>
 #include <log/logger_manager.h>
+#include <log/logger_manager_impl.h>
 #include <log/logger_name.h>
 #include <log/logger_support.h>
-#include <log/messagedef.h>
+#include <log/log_messages.h>
+#include <log/macros.h>
 #include <log/message_dictionary.h>
 #include <log/message_exception.h>
 #include <log/message_initializer.h>
+#include <log/message_initializer.h>
 #include <log/message_reader.h>
 #include <log/message_types.h>
-#include <log/macros.h>
-#include <log/messagedef.h>
-#include <log/message_initializer.h>
 
 using namespace std;
 
@@ -125,7 +124,7 @@ LoggerManager::init(const std::string& root, isc::log::Severity severity,
         sort(duplicates.begin(), duplicates.end());
         for (vector<string>::iterator i = duplicates.begin();
              i != duplicates.end(); ++i) {
-            LOG_WARN(logger, MSG_DUPMSGID).arg(*i);
+            LOG_WARN(logger, LOG_DUPLICATE_MESSAGE_ID).arg(*i);
         }
 
     }
@@ -147,7 +146,7 @@ LoggerManager::readLocalMessageFile(const char* file) {
     MessageReader reader(&dictionary);
     try {
 
-        logger.info(MSG_RDLOCMES).arg(file);
+        logger.info(LOG_READING_LOCAL_FILE).arg(file);
         reader.readFile(file, MessageReader::REPLACE);
 
         // File successfully read.  As each message in the file is supposed to
@@ -158,7 +157,7 @@ LoggerManager::readLocalMessageFile(const char* file) {
         for (MessageReader::MessageIDCollection::const_iterator
             i = unknown.begin(); i != unknown.end(); ++i) {
             string message_id = boost::lexical_cast<string>(*i);
-                logger.warn(MSG_IDNOTFND).arg(message_id);
+                logger.warn(LOG_NO_SUCH_MESSAGE).arg(message_id);
         }
     }
     catch (MessageException& e) {

+ 7 - 7
src/lib/log/logger_manager_impl.cc

@@ -21,13 +21,13 @@
 #include <log4cplus/fileappender.h>
 #include <log4cplus/syslogappender.h>
 
-#include "log/logger.h"
-#include "log/logger_level_impl.h"
-#include "log/logger_manager.h"
-#include "log/logger_manager_impl.h"
-#include "log/logger_name.h"
-#include "log/logger_specification.h"
-#include "log/messagedef.h"
+#include <log/logger.h>
+#include <log/logger_level_impl.h>
+#include <log/logger_manager.h>
+#include <log/logger_manager_impl.h>
+#include <log/log_messages.h>
+#include <log/logger_name.h>
+#include <log/logger_specification.h>
 
 using namespace std;
 

+ 29 - 0
src/lib/log/logimpl_messages.cc

@@ -0,0 +1,29 @@
+// File created from logimpl_messages.mes on Wed Jun 22 10:57:02 2011
+
+#include <cstddef>
+#include <log/message_types.h>
+#include <log/message_initializer.h>
+
+namespace isc {
+namespace log {
+
+extern const isc::log::MessageID LOGIMPL_ABOVE_MAX_DEBUG = "LOGIMPL_ABOVE_MAX_DEBUG";
+extern const isc::log::MessageID LOGIMPL_BAD_DEBUG_STRING = "LOGIMPL_BAD_DEBUG_STRING";
+extern const isc::log::MessageID LOGIMPL_BELOW_MIN_DEBUG = "LOGIMPL_BELOW_MIN_DEBUG";
+
+} // namespace log
+} // namespace isc
+
+namespace {
+
+const char* values[] = {
+    "LOGIMPL_ABOVE_MAX_DEBUG", "debug level of %1 is too high and will be set to the maximum of %2",
+    "LOGIMPL_BAD_DEBUG_STRING", "debug string '%1' has invalid format",
+    "LOGIMPL_BELOW_MIN_DEBUG", "debug level of %1 is too low and will be set to the minimum of %2",
+    NULL
+};
+
+const isc::log::MessageInitializer initializer(values);
+
+} // Anonymous namespace
+

+ 18 - 0
src/lib/log/logimpl_messages.h

@@ -0,0 +1,18 @@
+// File created from logimpl_messages.mes on Wed Jun 22 10:57:02 2011
+
+#ifndef __LOGIMPL_MESSAGES_H
+#define __LOGIMPL_MESSAGES_H
+
+#include <log/message_types.h>
+
+namespace isc {
+namespace log {
+
+extern const isc::log::MessageID LOGIMPL_ABOVE_MAX_DEBUG;
+extern const isc::log::MessageID LOGIMPL_BAD_DEBUG_STRING;
+extern const isc::log::MessageID LOGIMPL_BELOW_MIN_DEBUG;
+
+} // namespace log
+} // namespace isc
+
+#endif // __LOGIMPL_MESSAGES_H

+ 43 - 0
src/lib/log/logimpl_messages.mes

@@ -0,0 +1,43 @@
+# Copyright (C) 2011  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.
+
+# \brief Logger Implementation Messages
+#
+# This holds messages generated by the underlying logger implementation.  They
+# are likely to be specific to that implementation, and may well change if the
+# underlying implementation is changed.  For that reason, they have been put
+# in a separate file.
+
+$NAMESPACE isc::log
+
+% LOGIMPL_ABOVE_MAX_DEBUG debug level of %1 is too high and will be set to the maximum of %2
+A message from the interface to the underlying logger implementation reporting
+that the debug level (as set by an internally-created string DEBUGn, where n
+is an integer, e.g. DEBUG22) is above the maximum allowed value and has
+been reduced to that value.  The appearance of this message may indicate
+a programming error - please submit a bug report.
+
+% LOGIMPL_BAD_DEBUG_STRING debug string '%1' has invalid format
+A message from the interface to the underlying logger implementation
+reporting that an internally-created string used to set the debug level
+is not of the correct format (it should be of the form DEBUGn, where n
+is an integer, e.g. DEBUG22).  The appearance of this message indicates
+a programming error - please submit a bug report.
+
+% LOGIMPL_BELOW_MIN_DEBUG debug level of %1 is too low and will be set to the minimum of %2
+A message from the interface to the underlying logger implementation reporting
+that the debug level (as set by an internally-created string DEBUGn, where n
+is an integer, e.g. DEBUG22) is below the minimum allowed value and has
+been increased to that value.  The appearance of this message may indicate
+a programming error - please submit a bug report.

+ 14 - 14
src/lib/log/message_reader.cc

@@ -20,8 +20,8 @@
 #include <iostream>
 #include <fstream>
 
+#include <log/log_messages.h>
 #include <log/message_exception.h>
-#include <log/messagedef.h>
 #include <log/message_reader.h>
 #include <util/strutil.h>
 
@@ -48,7 +48,7 @@ MessageReader::readFile(const string& file, MessageReader::Mode mode) {
     // Open the file.
     ifstream infile(file.c_str());
     if (infile.fail()) {
-        throw MessageException(MSG_OPENIN, file, strerror(errno));
+        throw MessageException(LOG_INPUT_OPEN_FAIL, file, strerror(errno));
     }
 
     // Loop round reading it.  As we process the file one line at a time,
@@ -65,7 +65,7 @@ MessageReader::readFile(const string& file, MessageReader::Mode mode) {
 
     // Why did the loop terminate?
     if (!infile.eof()) {
-        throw MessageException(MSG_READERR, file, strerror(errno));
+        throw MessageException(LOG_READ_ERROR, file, strerror(errno));
     }
     infile.close();
 }
@@ -114,7 +114,7 @@ MessageReader::parseDirective(const std::string& text) {
     } else {
 
         // Unrecognised directive
-        throw MessageException(MSG_UNRECDIR, tokens[0], lineno_);
+        throw MessageException(LOG_UNRECOGNISED_DIRECTIVE, tokens[0], lineno_);
     }
 }
 
@@ -138,13 +138,13 @@ MessageReader::parsePrefix(const vector<string>& tokens) {
         // and numeric characters (and underscores) and does not start with a
         // digit.
         if (invalidSymbol(prefix_)) {
-            throw MessageException(MSG_PRFINVARG, prefix_, lineno_);
+            throw MessageException(LOG_PREFIX_INVALID_ARG, prefix_, lineno_);
         }
 
     } else {
 
         // Too many arguments
-        throw MessageException(MSG_PRFEXTRARG, lineno_);
+        throw MessageException(LOG_PREFIX_EXTRA_ARGS, lineno_);
     }
 }
 
@@ -172,10 +172,10 @@ MessageReader::parseNamespace(const vector<string>& tokens) {
 
     // Check argument count
     if (tokens.size() < 2) {
-        throw MessageException(MSG_NSNOARG, lineno_);
+        throw MessageException(LOG_NAMESPACE_NO_ARGS, lineno_);
 
     } else if (tokens.size() > 2) {
-        throw MessageException(MSG_NSEXTRARG, lineno_);
+        throw MessageException(LOG_NAMESPACE_EXTRA_ARGS, lineno_);
 
     }
 
@@ -187,12 +187,12 @@ MessageReader::parseNamespace(const vector<string>& tokens) {
                                       "abcdefghijklmnopqrstuvwxyz"
                                       "0123456789_:";
     if (tokens[1].find_first_not_of(valid_chars) != string::npos) {
-        throw MessageException(MSG_NSINVARG, tokens[1], lineno_);
+        throw MessageException(LOG_NAMESPACE_INVALID_ARG, tokens[1], lineno_);
     }
 
     // All OK - unless the namespace has already been set.
     if (ns_.size() != 0) {
-        throw MessageException(MSG_DUPLNS, lineno_);
+        throw MessageException(LOG_DUPLICATE_NAMESPACE, lineno_);
     }
 
     // Prefix has not been set, so set it and return success.
@@ -219,7 +219,7 @@ MessageReader::parseMessage(const std::string& text, MessageReader::Mode mode) {
 
     // A line comprising just the message introducer is not valid.
     if (text.size() == 1) {
-        throw MessageException(MSG_NOMSGID, text, lineno_);
+        throw MessageException(LOG_NO_MESSAGE_ID, text, lineno_);
     }
 
     // Strip off the introducer and any leading space after that.
@@ -230,7 +230,7 @@ MessageReader::parseMessage(const std::string& text, MessageReader::Mode mode) {
     if (first_delim == string::npos) {
 
         // Just a single token in the line - this is not valid
-        throw MessageException(MSG_NOMSGTXT, message_line, lineno_);
+        throw MessageException(LOG_NO_MESSAGE_TEXT, message_line, lineno_);
     }
 
     // Extract the first token into the message ID, preceding it with the
@@ -240,7 +240,7 @@ MessageReader::parseMessage(const std::string& text, MessageReader::Mode mode) {
     string ident = prefix_ + message_line.substr(0, first_delim);
     if (prefix_.empty()) {
         if (invalidSymbol(ident)) {
-            throw MessageException(MSG_INVMSGID, ident, lineno_);
+            throw MessageException(LOG_INVALID_MESSAGE_ID, ident, lineno_);
         }
     }
     isc::util::str::uppercase(ident);
@@ -252,7 +252,7 @@ MessageReader::parseMessage(const std::string& text, MessageReader::Mode mode) {
         // ?? This happens if there are trailing delimiters, which should not
         // occur as we have stripped trailing spaces off the line.  Just treat
         // this as a single-token error for simplicity's sake.
-        throw MessageException(MSG_NOMSGTXT, message_line, lineno_);
+        throw MessageException(LOG_NO_MESSAGE_TEXT, message_line, lineno_);
     }
 
     // Add the result to the dictionary and to the non-added list if the add to

+ 0 - 63
src/lib/log/messagedef.cc

@@ -1,63 +0,0 @@
-// File created from messagedef.mes on Fri May 27 14:49:45 2011
-
-#include <cstddef>
-#include <log/message_types.h>
-#include <log/message_initializer.h>
-
-namespace isc {
-namespace log {
-
-extern const isc::log::MessageID MSG_BADDESTINATION = "MSG_BADDESTINATION";
-extern const isc::log::MessageID MSG_BADSEVERITY = "MSG_BADSEVERITY";
-extern const isc::log::MessageID MSG_BADSTREAM = "MSG_BADSTREAM";
-extern const isc::log::MessageID MSG_DUPLNS = "MSG_DUPLNS";
-extern const isc::log::MessageID MSG_DUPMSGID = "MSG_DUPMSGID";
-extern const isc::log::MessageID MSG_IDNOTFND = "MSG_IDNOTFND";
-extern const isc::log::MessageID MSG_INVMSGID = "MSG_INVMSGID";
-extern const isc::log::MessageID MSG_NOMSGID = "MSG_NOMSGID";
-extern const isc::log::MessageID MSG_NOMSGTXT = "MSG_NOMSGTXT";
-extern const isc::log::MessageID MSG_NSEXTRARG = "MSG_NSEXTRARG";
-extern const isc::log::MessageID MSG_NSINVARG = "MSG_NSINVARG";
-extern const isc::log::MessageID MSG_NSNOARG = "MSG_NSNOARG";
-extern const isc::log::MessageID MSG_OPENIN = "MSG_OPENIN";
-extern const isc::log::MessageID MSG_OPENOUT = "MSG_OPENOUT";
-extern const isc::log::MessageID MSG_PRFEXTRARG = "MSG_PRFEXTRARG";
-extern const isc::log::MessageID MSG_PRFINVARG = "MSG_PRFINVARG";
-extern const isc::log::MessageID MSG_RDLOCMES = "MSG_RDLOCMES";
-extern const isc::log::MessageID MSG_READERR = "MSG_READERR";
-extern const isc::log::MessageID MSG_UNRECDIR = "MSG_UNRECDIR";
-extern const isc::log::MessageID MSG_WRITERR = "MSG_WRITERR";
-
-} // namespace log
-} // namespace isc
-
-namespace {
-
-const char* values[] = {
-    "MSG_BADDESTINATION", "unrecognized log destination: %1",
-    "MSG_BADSEVERITY", "unrecognized log severity: %1",
-    "MSG_BADSTREAM", "bad log console output stream: %1",
-    "MSG_DUPLNS", "line %1: duplicate $NAMESPACE directive found",
-    "MSG_DUPMSGID", "duplicate message ID (%1) in compiled code",
-    "MSG_IDNOTFND", "could not replace message text for '%1': no such message",
-    "MSG_INVMSGID", "line %1: invalid message identification '%2'",
-    "MSG_NOMSGID", "line %1: message definition line found without a message ID",
-    "MSG_NOMSGTXT", "line %1: line found containing a message ID ('%2') and no text",
-    "MSG_NSEXTRARG", "line %1: $NAMESPACE directive has too many arguments",
-    "MSG_NSINVARG", "line %1: $NAMESPACE directive has an invalid argument ('%2')",
-    "MSG_NSNOARG", "line %1: no arguments were given to the $NAMESPACE directive",
-    "MSG_OPENIN", "unable to open message file %1 for input: %2",
-    "MSG_OPENOUT", "unable to open %1 for output: %2",
-    "MSG_PRFEXTRARG", "line %1: $PREFIX directive has too many arguments",
-    "MSG_PRFINVARG", "line %1: $PREFIX directive has an invalid argument ('%2')",
-    "MSG_RDLOCMES", "reading local message file %1",
-    "MSG_READERR", "error reading from message file %1: %2",
-    "MSG_UNRECDIR", "line %1: unrecognised directive '%2'",
-    "MSG_WRITERR", "error writing to %1: %2",
-    NULL
-};
-
-const isc::log::MessageInitializer initializer(values);
-
-} // Anonymous namespace
-

+ 0 - 35
src/lib/log/messagedef.h

@@ -1,35 +0,0 @@
-// File created from messagedef.mes on Fri May 27 14:49:45 2011
-
-#ifndef __MESSAGEDEF_H
-#define __MESSAGEDEF_H
-
-#include <log/message_types.h>
-
-namespace isc {
-namespace log {
-
-extern const isc::log::MessageID MSG_BADDESTINATION;
-extern const isc::log::MessageID MSG_BADSEVERITY;
-extern const isc::log::MessageID MSG_BADSTREAM;
-extern const isc::log::MessageID MSG_DUPLNS;
-extern const isc::log::MessageID MSG_DUPMSGID;
-extern const isc::log::MessageID MSG_IDNOTFND;
-extern const isc::log::MessageID MSG_INVMSGID;
-extern const isc::log::MessageID MSG_NOMSGID;
-extern const isc::log::MessageID MSG_NOMSGTXT;
-extern const isc::log::MessageID MSG_NSEXTRARG;
-extern const isc::log::MessageID MSG_NSINVARG;
-extern const isc::log::MessageID MSG_NSNOARG;
-extern const isc::log::MessageID MSG_OPENIN;
-extern const isc::log::MessageID MSG_OPENOUT;
-extern const isc::log::MessageID MSG_PRFEXTRARG;
-extern const isc::log::MessageID MSG_PRFINVARG;
-extern const isc::log::MessageID MSG_RDLOCMES;
-extern const isc::log::MessageID MSG_READERR;
-extern const isc::log::MessageID MSG_UNRECDIR;
-extern const isc::log::MessageID MSG_WRITERR;
-
-} // namespace log
-} // namespace isc
-
-#endif // __MESSAGEDEF_H

+ 0 - 131
src/lib/log/messagedef.mes

@@ -1,131 +0,0 @@
-# Copyright (C) 2011  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.
-
-# \brief Message Utility Message File
-#
-# This is the source of the set of messages generated by the message and
-# logging components.  The associated .h and .cc files are created by hand from
-# this file though and are not built during the build process; this is to avoid
-# the chicken-and-egg situation where we need the files to build the message
-# compiler, yet we need the compiler to build the files.
-
-$PREFIX MSG_
-$NAMESPACE isc::log
-
-% DUPMSGID      duplicate message ID (%1) in compiled code
-Indicative of a programming error, when it started up, BIND10 detected that
-the given message ID had been registered by one or more modules.  (All message
-IDs should be unique throughout BIND10.)  This has no impact on the operation
-of the server other that erroneous messages may be logged.  (When BIND10 loads
-the message IDs (and their associated text), if a duplicate ID is found it is
-discarded.  However, when the module that supplied the duplicate ID logs that
-particular message, the text supplied by the module that added the original
-ID will be output - something that may bear no relation to the condition being
-logged.
-
-% DUPLNS        line %1: duplicate $NAMESPACE directive found
-When reading a message file, more than one $NAMESPACE directive was found.  In
-this version of the code, such a condition is regarded as an error and the
-read will be abandoned.
-
-% IDNOTFND      could not replace message text for '%1': no such message
-During start-up a local message file was read.  A line with the listed
-message identification was found in the file, but the identification is not
-one contained in the compiled-in message dictionary.  Either the message
-identification has been mis-spelled in the file, or the local file was used
-for an earlier version of the software and the message with that
-identification has been removed.
-
-This message may appear a number of times in the file, once for every such
-unknown message identification.
-
-% INVMSGID      line %1: invalid message identification '%2'
-The concatenation of the prefix and the message identification is used as
-a symbol in the C++ module; as such it may only contain 
-
-% NOMSGID       line %1: message definition line found without a message ID
-Message definition lines are lines starting with a "%".  The rest of the line
-should comprise the message ID and text describing the message.  This error
-indicates the message compiler found a line in the message file comprising
-just the "%" and nothing else.
-
-% NOMSGTXT      line %1: line found containing a message ID ('%2') and no text
-Message definition lines are lines starting with a "%".  The rest of the line
-should comprise the message ID and text describing the message.  This error
-is generated when a line is found in the message file that contains the
-leading "%" and the message identification but no text.
-
-% NSEXTRARG     line %1: $NAMESPACE directive has too many arguments
-The $NAMESPACE directive takes a single argument, a namespace in which all the
-generated symbol names are placed.  This error is generated when the
-compiler finds a $NAMESPACE directive with more than one argument.
-
-% NSINVARG      line %1: $NAMESPACE directive has an invalid argument ('%2')
-The $NAMESPACE argument should be a valid C++ namespace.  The reader does a
-cursory check on its validity, checking that the characters in the namespace
-are correct.  The error is generated when the reader finds an invalid
-character. (Valid are alphanumeric characters, underscores and colons.)
-
-% NSNOARG       line %1: no arguments were given to the $NAMESPACE directive
-The $NAMESPACE directive takes a single argument, a namespace in which all the
-generated symbol names are placed.  This error is generated when the
-compiler finds a $NAMESPACE directive with no arguments.
-
-% OPENIN        unable to open message file %1 for input: %2
-The program was not able to open the specified input message file for the
-reason given.
-
-% OPENOUT       unable to open %1 for output: %2
-The program was not able to open the specified output file for the reason
-given.
-
-% PRFEXTRARG    line %1: $PREFIX directive has too many arguments
-The $PREFIX directive takes a single argument, a prefix to be added to the
-symbol names when a C++ .h file is created.  This error is generated when the
-compiler finds a $PREFIX directive with more than one argument.
-
-% PRFINVARG     line %1: $PREFIX directive has an invalid argument ('%2')
-The $PREFIX argument is used in a symbol name in a C++ header file.  As such,
-it must adhere to restrictions on C++ symbol names (e.g. may only contain
-alphanumeric characters or underscores, and may nor start with a digit).
-A $PREFIX directive was found with an argument (given in the message) that
-violates those restictions.
-
-% RDLOCMES      reading local message file %1
-This is an informational message output by BIND10 when it starts to read a
-local message file.  (A local message file may replace the text of one of more
-messages; the ID of the message will not be changed though.)
-
-% READERR       error reading from message file %1: %2
-The specified error was encountered reading from the named message file.
-
-% WRITERR       error writing to %1: %2
-The specified error was encountered by the message compiler when writing to
-the named output file.
-
-% UNRECDIR      line %1: unrecognised directive '%2'
-A line starting with a dollar symbol was found, but the first word on the line
-(shown in the message) was not a recognised message compiler directive.
-
-% BADSEVERITY   unrecognized log severity: %1
-A logger severity value was given that was not recognized. The severity
-should be one of "DEBUG", "INFO", "WARN", "ERROR", or "FATAL".
-
-% BADDESTINATION unrecognized log destination: %1
-A logger destination value was given that was not recognized. The
-destination should be one of "console", "file", or "syslog".
-
-% BADSTREAM     bad log console output stream: %1
-A log console output stream was given that was not recognized. The
-output stream should be one of "stdout", or "stderr"

+ 6 - 5
src/lib/log/output_option.cc

@@ -13,12 +13,13 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <string>
-#include <log/output_option.h>
-#include <log/macros.h>
-#include <log/messagedef.h>
 
 #include <boost/algorithm/string.hpp>
 
+#include <log/log_messages.h>
+#include <log/macros.h>
+#include <log/output_option.h>
+
 namespace isc {
 namespace log {
 
@@ -32,7 +33,7 @@ getDestination(const std::string& dest_str) {
         return OutputOption::DEST_SYSLOG;
     } else {
         Logger logger("log");
-        LOG_ERROR(logger, MSG_BADDESTINATION).arg(dest_str);
+        LOG_ERROR(logger, LOG_BAD_DESTINATION).arg(dest_str);
         return OutputOption::DEST_CONSOLE;
     }
 }
@@ -45,7 +46,7 @@ getStream(const std::string& stream_str) {
         return OutputOption::STR_STDOUT;
     } else {
         Logger logger("log");
-        LOG_ERROR(logger, MSG_BADSTREAM).arg(stream_str);
+        LOG_ERROR(logger, LOG_BAD_STREAM).arg(stream_str);
         return OutputOption::STR_STDOUT;
     }
 }

+ 12 - 12
src/lib/log/tests/destination_test.sh.in

@@ -37,10 +37,10 @@ passfail() {
 
 echo "1. One logger, multiple destinations:"
 cat > $tempfile << .
-FATAL [example] MSG_WRITERR error writing to test1: 42
-ERROR [example] MSG_RDLOCMES reading local message file dummy/file
-FATAL [example.beta] MSG_BADSEVERITY unrecognized log severity: beta_fatal
-ERROR [example.beta] MSG_BADDESTINATION unrecognized log destination: beta_error
+FATAL [example] LOG_WRITE_ERROR error writing to test1: 42
+ERROR [example] LOG_READING_LOCAL_FILE reading local message file dummy/file
+FATAL [example.beta] LOG_BAD_SEVERITY unrecognized log severity: beta_fatal
+ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_error
 .
 rm -f $destfile1 $destfile2
 ./logger_example -s error -f $destfile1 -f $destfile2
@@ -61,13 +61,13 @@ rm -f $destfile1 $destfile2
 # Output for example.alpha should have done to destfile2.
 
 cat > $tempfile << .
-FATAL [example] MSG_WRITERR error writing to test1: 42
-ERROR [example] MSG_RDLOCMES reading local message file dummy/file
-WARN  [example] MSG_BADSTREAM bad log console output stream: example
-FATAL [example.beta] MSG_BADSEVERITY unrecognized log severity: beta_fatal
-ERROR [example.beta] MSG_BADDESTINATION unrecognized log destination: beta_error
-WARN  [example.beta] MSG_BADSTREAM bad log console output stream: beta_warn
-INFO  [example.beta] MSG_READERR error reading from message file beta: info
+FATAL [example] LOG_WRITE_ERROR error writing to test1: 42
+ERROR [example] LOG_READING_LOCAL_FILE reading local message file dummy/file
+WARN  [example] LOG_BAD_STREAM bad log console output stream: example
+FATAL [example.beta] LOG_BAD_SEVERITY unrecognized log severity: beta_fatal
+ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_error
+WARN  [example.beta] LOG_BAD_STREAM bad log console output stream: beta_warn
+INFO  [example.beta] LOG_READ_ERROR error reading from message file beta: info
 .
 echo -n  "   - destination 1:"
 cut -d' ' -f3- $destfile1 | diff $tempfile -
@@ -75,7 +75,7 @@ passfail $?
 
 echo -n  "   - destination 2:"
 cat > $tempfile << .
-WARN  [example.alpha] MSG_READERR error reading from message file a.txt: dummy reason
+WARN  [example.alpha] LOG_READ_ERROR error reading from message file a.txt: dummy reason
 .
 cut -d' ' -f3- $destfile2 | diff $tempfile -
 passfail $?

+ 19 - 19
src/lib/log/tests/local_file_test.sh.in

@@ -37,35 +37,35 @@ passfail() {
 # Create the local message file for testing
 
 cat > $localmes << .
-% MSG_NOTHERE     this message is not in the global dictionary
-% MSG_READERR     replacement read error, parameters: '%1' and '%2'
-% MSG_RDLOCMES    replacement read local message file, parameter is '%1'
+% LOG_NOTHERE this message is not in the global dictionary
+% LOG_READ_ERROR replacement read error, parameters: '%1' and '%2'
+% LOG_READING_LOCAL_FILE replacement read local message file, parameter is '%1'
 .
 
 echo -n "1. Local message replacement:"
 cat > $tempfile << .
-WARN  [example.log] MSG_IDNOTFND could not replace message text for 'MSG_NOTHERE': no such message
-FATAL [example] MSG_WRITERR error writing to test1: 42
-ERROR [example] MSG_RDLOCMES replacement read local message file, parameter is 'dummy/file'
-WARN  [example] MSG_BADSTREAM bad log console output stream: example
-WARN  [example.alpha] MSG_READERR replacement read error, parameters: 'a.txt' and 'dummy reason'
-FATAL [example.beta] MSG_BADSEVERITY unrecognized log severity: beta_fatal
-ERROR [example.beta] MSG_BADDESTINATION unrecognized log destination: beta_error
-WARN  [example.beta] MSG_BADSTREAM bad log console output stream: beta_warn
+WARN  [example.log] LOG_NO_SUCH_MESSAGE could not replace message text for 'LOG_NOTHERE': no such message
+FATAL [example] LOG_WRITE_ERROR error writing to test1: 42
+ERROR [example] LOG_READING_LOCAL_FILE replacement read local message file, parameter is 'dummy/file'
+WARN  [example] LOG_BAD_STREAM bad log console output stream: example
+WARN  [example.alpha] LOG_READ_ERROR replacement read error, parameters: 'a.txt' and 'dummy reason'
+FATAL [example.beta] LOG_BAD_SEVERITY unrecognized log severity: beta_fatal
+ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_error
+WARN  [example.beta] LOG_BAD_STREAM bad log console output stream: beta_warn
 .
 ./logger_example -c stdout -s warn $localmes | cut -d' ' -f3- | diff $tempfile -
 passfail $?
 
 echo -n "2. Report error if unable to read local message file:"
 cat > $tempfile << .
-ERROR [example.log] MSG_OPENIN unable to open message file $localmes for input: No such file or directory
-FATAL [example] MSG_WRITERR error writing to test1: 42
-ERROR [example] MSG_RDLOCMES reading local message file dummy/file
-WARN  [example] MSG_BADSTREAM bad log console output stream: example
-WARN  [example.alpha] MSG_READERR error reading from message file a.txt: dummy reason
-FATAL [example.beta] MSG_BADSEVERITY unrecognized log severity: beta_fatal
-ERROR [example.beta] MSG_BADDESTINATION unrecognized log destination: beta_error
-WARN  [example.beta] MSG_BADSTREAM bad log console output stream: beta_warn
+ERROR [example.log] LOG_INPUT_OPEN_FAIL unable to open message file $localmes for input: No such file or directory
+FATAL [example] LOG_WRITE_ERROR error writing to test1: 42
+ERROR [example] LOG_READING_LOCAL_FILE reading local message file dummy/file
+WARN  [example] LOG_BAD_STREAM bad log console output stream: example
+WARN  [example.alpha] LOG_READ_ERROR error reading from message file a.txt: dummy reason
+FATAL [example.beta] LOG_BAD_SEVERITY unrecognized log severity: beta_fatal
+ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_error
+WARN  [example.beta] LOG_BAD_STREAM bad log console output stream: beta_warn
 .
 rm -f $localmes
 ./logger_example -c stdout -s warn $localmes | cut -d' ' -f3- | diff $tempfile -

+ 16 - 16
src/lib/log/tests/logger_example.cc

@@ -40,7 +40,7 @@
 #include <log/macros.h>
 
 // Include a set of message definitions.
-#include <log/messagedef.h>
+#include <log/log_messages.h>
 
 using namespace isc::log;
 using namespace std;
@@ -285,21 +285,21 @@ int main(int argc, char** argv) {
     isc::log::Logger logger_alpha("alpha");
     isc::log::Logger logger_beta("beta");
 
-    LOG_FATAL(logger_ex, MSG_WRITERR).arg("test1").arg("42");
-    LOG_ERROR(logger_ex, MSG_RDLOCMES).arg("dummy/file");
-    LOG_WARN(logger_ex, MSG_BADSTREAM).arg("example");
-    LOG_WARN(logger_alpha, MSG_READERR).arg("a.txt").arg("dummy reason");
-    LOG_INFO(logger_alpha, MSG_OPENIN).arg("example.msg").arg("dummy reason");
-    LOG_DEBUG(logger_ex, 0, MSG_RDLOCMES).arg("example/0");
-    LOG_DEBUG(logger_ex, 24, MSG_RDLOCMES).arg("example/24");
-    LOG_DEBUG(logger_ex, 25, MSG_RDLOCMES).arg("example/25");
-    LOG_DEBUG(logger_ex, 26, MSG_RDLOCMES).arg("example/26");
-    LOG_FATAL(logger_beta, MSG_BADSEVERITY).arg("beta_fatal");
-    LOG_ERROR(logger_beta, MSG_BADDESTINATION).arg("beta_error");
-    LOG_WARN(logger_beta, MSG_BADSTREAM).arg("beta_warn");
-    LOG_INFO(logger_beta, MSG_READERR).arg("beta").arg("info");
-    LOG_DEBUG(logger_beta, 25, MSG_BADSEVERITY).arg("beta/25");
-    LOG_DEBUG(logger_beta, 26, MSG_BADSEVERITY).arg("beta/26");
+    LOG_FATAL(logger_ex, LOG_WRITE_ERROR).arg("test1").arg("42");
+    LOG_ERROR(logger_ex, LOG_READING_LOCAL_FILE).arg("dummy/file");
+    LOG_WARN(logger_ex, LOG_BAD_STREAM).arg("example");
+    LOG_WARN(logger_alpha, LOG_READ_ERROR).arg("a.txt").arg("dummy reason");
+    LOG_INFO(logger_alpha, LOG_INPUT_OPEN_FAIL).arg("example.msg").arg("dummy reason");
+    LOG_DEBUG(logger_ex, 0, LOG_READING_LOCAL_FILE).arg("example/0");
+    LOG_DEBUG(logger_ex, 24, LOG_READING_LOCAL_FILE).arg("example/24");
+    LOG_DEBUG(logger_ex, 25, LOG_READING_LOCAL_FILE).arg("example/25");
+    LOG_DEBUG(logger_ex, 26, LOG_READING_LOCAL_FILE).arg("example/26");
+    LOG_FATAL(logger_beta, LOG_BAD_SEVERITY).arg("beta_fatal");
+    LOG_ERROR(logger_beta, LOG_BAD_DESTINATION).arg("beta_error");
+    LOG_WARN(logger_beta, LOG_BAD_STREAM).arg("beta_warn");
+    LOG_INFO(logger_beta, LOG_READ_ERROR).arg("beta").arg("info");
+    LOG_DEBUG(logger_beta, 25, LOG_BAD_SEVERITY).arg("beta/25");
+    LOG_DEBUG(logger_beta, 26, LOG_BAD_SEVERITY).arg("beta/26");
 
     return (0);
 }

+ 1 - 1
src/lib/log/tests/logger_level_unittest.cc

@@ -19,8 +19,8 @@
 
 #include <log/logger.h>
 #include <log/logger_manager.h>
+#include <log/log_messages.h>
 #include <log/logger_name.h>
-#include <log/messagedef.h>
 
 using namespace isc;
 using namespace isc::log;

+ 19 - 19
src/lib/log/tests/logger_manager_unittest.cc

@@ -27,7 +27,7 @@
 #include <exceptions/exceptions.h>
 
 #include <log/macros.h>
-#include <log/messagedef.h>
+#include <log/log_messages.h>
 #include <log/logger.h>
 #include <log/logger_level.h>
 #include <log/logger_manager.h>
@@ -203,16 +203,16 @@ TEST_F(LoggerManagerTest, FileLogger) {
         // keep the file open.
         Logger logger(file_spec.getLoggerName());
 
-        LOG_FATAL(logger, MSG_DUPMSGID).arg("test");
-        ids.push_back(MSG_DUPMSGID);
+        LOG_FATAL(logger, LOG_DUPLICATE_MESSAGE_ID).arg("test");
+        ids.push_back(LOG_DUPLICATE_MESSAGE_ID);
 
-        LOG_FATAL(logger, MSG_DUPLNS).arg("test");
-        ids.push_back(MSG_DUPLNS);
+        LOG_FATAL(logger, LOG_DUPLICATE_NAMESPACE).arg("test");
+        ids.push_back(LOG_DUPLICATE_NAMESPACE);
     }
     LoggerManager::reset();
 
     // At this point, the output file should contain two lines with messages
-    // MSG_DUPMSGID and MSG_DUPLNS messages - test this.
+    // LOG_DUPLICATE_MESSAGE_ID and LOG_DUPLICATE_NAMESPACE messages - test this.
     checkFileContents(file_spec.getFileName(), ids.begin(), ids.end());
 
     // Re-open the file (we have to assume that it was closed when we
@@ -225,14 +225,14 @@ TEST_F(LoggerManagerTest, FileLogger) {
     // Create a new instance of the logger and log three more messages.
     Logger logger(file_spec.getLoggerName());
 
-    LOG_FATAL(logger, MSG_IDNOTFND).arg("test");
-    ids.push_back(MSG_IDNOTFND);
+    LOG_FATAL(logger, LOG_NO_SUCH_MESSAGE).arg("test");
+    ids.push_back(LOG_NO_SUCH_MESSAGE);
 
-    LOG_FATAL(logger, MSG_INVMSGID).arg("test").arg("test2");
-    ids.push_back(MSG_INVMSGID);
+    LOG_FATAL(logger, LOG_INVALID_MESSAGE_ID).arg("test").arg("test2");
+    ids.push_back(LOG_INVALID_MESSAGE_ID);
 
-    LOG_FATAL(logger, MSG_NOMSGID).arg("42");
-    ids.push_back(MSG_NOMSGID);
+    LOG_FATAL(logger, LOG_NO_MESSAGE_ID).arg("42");
+    ids.push_back(LOG_NO_MESSAGE_ID);
 
     // Close the file and check again
     LoggerManager::reset();
@@ -276,19 +276,19 @@ TEST_F(LoggerManagerTest, FileSizeRollover) {
     // be rolled after the message is logged.
     {
         Logger logger(file_spec.getLoggerName());
-        LOG_FATAL(logger, MSG_IDNOTFND).arg(big_arg);
-        LOG_FATAL(logger, MSG_DUPLNS).arg(big_arg);
+        LOG_FATAL(logger, LOG_NO_SUCH_MESSAGE).arg(big_arg);
+        LOG_FATAL(logger, LOG_DUPLICATE_NAMESPACE).arg(big_arg);
     }
 
     // Check them.
     LoggerManager::reset();     // Ensure files are closed
 
     vector<MessageID> ids;
-    ids.push_back(MSG_IDNOTFND);
+    ids.push_back(LOG_NO_SUCH_MESSAGE);
     checkFileContents(prev_name[1], ids.begin(), ids.end());
 
     ids.clear();
-    ids.push_back(MSG_DUPLNS);
+    ids.push_back(LOG_DUPLICATE_NAMESPACE);
     checkFileContents(prev_name[0], ids.begin(), ids.end());
 
     // Log another message and check that the files have rotated and that
@@ -296,18 +296,18 @@ TEST_F(LoggerManagerTest, FileSizeRollover) {
     manager.process(spec);
     {
         Logger logger(file_spec.getLoggerName());
-        LOG_FATAL(logger, MSG_NOMSGTXT).arg(big_arg);
+        LOG_FATAL(logger, LOG_NO_MESSAGE_TEXT).arg(big_arg);
     }
 
     LoggerManager::reset();     // Ensure files are closed
 
     // Check that the files have moved.
     ids.clear();
-    ids.push_back(MSG_DUPLNS);
+    ids.push_back(LOG_DUPLICATE_NAMESPACE);
     checkFileContents(prev_name[1], ids.begin(), ids.end());
 
     ids.clear();
-    ids.push_back(MSG_NOMSGTXT);
+    ids.push_back(LOG_NO_MESSAGE_TEXT);
     checkFileContents(prev_name[0], ids.begin(), ids.end());
 
     // ... and check that the .3 version does not exist.

+ 3 - 3
src/lib/log/tests/logger_support_unittest.cc

@@ -14,7 +14,7 @@
 
 #include <gtest/gtest.h>
 #include <log/logger_support.h>
-#include <log/messagedef.h>
+#include <log/log_messages.h>
 
 using namespace isc::log;
 
@@ -63,10 +63,10 @@ TEST(LoggerSupportTest, LoggingInitializationCheck) {
     isc::log::Logger test_logger("test");
 
     EXPECT_THROW(test_logger.isDebugEnabled(), LoggingNotInitialized);
-    EXPECT_THROW(test_logger.info(MSG_OPENIN), LoggingNotInitialized);
+    EXPECT_THROW(test_logger.info(LOG_INPUT_OPEN_FAIL), LoggingNotInitialized);
 
     // ... and check that they work when logging is initialized.
     setLoggingInitialized(true);
     EXPECT_NO_THROW(test_logger.isDebugEnabled());
-    EXPECT_NO_THROW(test_logger.info(MSG_OPENIN));
+    EXPECT_NO_THROW(test_logger.info(LOG_INPUT_OPEN_FAIL));
 }

+ 1 - 1
src/lib/log/tests/logger_unittest.cc

@@ -20,7 +20,7 @@
 #include <log/logger.h>
 #include <log/logger_manager.h>
 #include <log/logger_name.h>
-#include <log/messagedef.h>
+#include <log/log_messages.h>
 
 using namespace isc;
 using namespace isc::log;

+ 2 - 2
src/lib/log/tests/message_dictionary_unittest.cc

@@ -29,7 +29,7 @@ using namespace std;
 // and the latter should be present.
 
 static const char* values[] = {
-    "MSG_DUPLNS", "duplicate $NAMESPACE directive found",
+    "LOG_DUPLICATE_NAMESPACE", "duplicate $NAMESPACE directive found",
     "NEWSYM", "new symbol added",
     NULL
 };
@@ -190,7 +190,7 @@ TEST_F(MessageDictionaryTest, GlobalTest) {
 TEST_F(MessageDictionaryTest, GlobalLoadTest) {
     vector<string>& duplicates = MessageInitializer::getDuplicates();
     ASSERT_EQ(1, duplicates.size());
-    EXPECT_EQ(string("MSG_DUPLNS"), duplicates[0]);
+    EXPECT_EQ(string("LOG_DUPLICATE_NAMESPACE"), duplicates[0]);
 
     string text = MessageDictionary::globalDictionary().getText("NEWSYM");
     EXPECT_EQ(string("new symbol added"), text);

+ 12 - 12
src/lib/log/tests/message_reader_unittest.cc

@@ -16,7 +16,7 @@
 #include <string>
 #include <gtest/gtest.h>
 
-#include <log/messagedef.h>
+#include <log/log_messages.h>
 #include <log/message_dictionary.h>
 #include <log/message_exception.h>
 #include <log/message_reader.h>
@@ -102,8 +102,8 @@ processLineException(MessageReader& reader, const char* what,
 TEST_F(MessageReaderTest, InvalidDirectives) {
 
     // Check that a "$" with nothing else generates an error
-    processLineException(reader_, "$", MSG_UNRECDIR);
-    processLineException(reader_, "$xyz", MSG_UNRECDIR);
+    processLineException(reader_, "$", LOG_UNRECOGNISED_DIRECTIVE);
+    processLineException(reader_, "$xyz", LOG_UNRECOGNISED_DIRECTIVE);
 }
 
 // Check that it can parse a prefix
@@ -117,20 +117,20 @@ TEST_F(MessageReaderTest, Prefix) {
     EXPECT_NO_THROW(reader_.processLine("$PREFIX"));
 
     // Check a $PREFIX with multiple arguments is invalid
-    processLineException(reader_, "$prefix A B", MSG_PRFEXTRARG);
+    processLineException(reader_, "$prefix A B", LOG_PREFIX_EXTRA_ARGS);
 
     // Prefixes should be alphanumeric (with underscores) and not start
     // with a number.
-    processLineException(reader_, "$prefix ab[cd", MSG_PRFINVARG);
-    processLineException(reader_, "$prefix 123", MSG_PRFINVARG);
-    processLineException(reader_, "$prefix 1ABC", MSG_PRFINVARG);
+    processLineException(reader_, "$prefix ab[cd", LOG_PREFIX_INVALID_ARG);
+    processLineException(reader_, "$prefix 123", LOG_PREFIX_INVALID_ARG);
+    processLineException(reader_, "$prefix 1ABC", LOG_PREFIX_INVALID_ARG);
 
     // A valid prefix should be accepted
     EXPECT_NO_THROW(reader_.processLine("$PREFIX   dlm__"));
     EXPECT_EQ(string("dlm__"), reader_.getPrefix());
 
     // And check that the parser fails on invalid prefixes...
-    processLineException(reader_, "$prefix 1ABC", MSG_PRFINVARG);
+    processLineException(reader_, "$prefix 1ABC", LOG_PREFIX_INVALID_ARG);
 
     // Check that we can clear the prefix as well
     reader_.clearPrefix();
@@ -150,13 +150,13 @@ TEST_F(MessageReaderTest, Namespace) {
     EXPECT_EQ(string(""), reader_.getNamespace());
 
     // Check that a $NAMESPACE directive with no argument generates an error.
-    processLineException(reader_, "$NAMESPACE", MSG_NSNOARG);
+    processLineException(reader_, "$NAMESPACE", LOG_NAMESPACE_NO_ARGS);
 
     // Check a $NAMESPACE with multiple arguments is invalid
-    processLineException(reader_, "$namespace A B", MSG_NSEXTRARG);
+    processLineException(reader_, "$namespace A B", LOG_NAMESPACE_EXTRA_ARGS);
 
     // Namespaces should be alphanumeric (with underscores and colons)
-    processLineException(reader_, "$namespace ab[cd", MSG_NSINVARG);
+    processLineException(reader_, "$namespace ab[cd", LOG_NAMESPACE_INVALID_ARG);
 
     // A valid $NAMESPACE should be accepted
     EXPECT_NO_THROW(reader_.processLine("$NAMESPACE isc"));
@@ -176,7 +176,7 @@ TEST_F(MessageReaderTest, Namespace) {
     EXPECT_EQ(string("::"), reader_.getNamespace());
 
     // ... and that another $NAMESPACE is rejected
-    processLineException(reader_, "$NAMESPACE ABC", MSG_DUPLNS);
+    processLineException(reader_, "$NAMESPACE ABC", LOG_DUPLICATE_NAMESPACE);
 }
 
 // Check that it can parse a line

+ 26 - 26
src/lib/log/tests/severity_test.sh.in

@@ -35,44 +35,44 @@ passfail() {
 
 echo -n "1. runInitTest default parameters:"
 cat > $tempfile << .
-FATAL [example] MSG_WRITERR error writing to test1: 42
-ERROR [example] MSG_RDLOCMES reading local message file dummy/file
-WARN  [example] MSG_BADSTREAM bad log console output stream: example
-WARN  [example.alpha] MSG_READERR error reading from message file a.txt: dummy reason
-INFO  [example.alpha] MSG_OPENIN unable to open message file example.msg for input: dummy reason
-FATAL [example.beta] MSG_BADSEVERITY unrecognized log severity: beta_fatal
-ERROR [example.beta] MSG_BADDESTINATION unrecognized log destination: beta_error
-WARN  [example.beta] MSG_BADSTREAM bad log console output stream: beta_warn
-INFO  [example.beta] MSG_READERR error reading from message file beta: info
+FATAL [example] LOG_WRITE_ERROR error writing to test1: 42
+ERROR [example] LOG_READING_LOCAL_FILE reading local message file dummy/file
+WARN  [example] LOG_BAD_STREAM bad log console output stream: example
+WARN  [example.alpha] LOG_READ_ERROR error reading from message file a.txt: dummy reason
+INFO  [example.alpha] LOG_INPUT_OPEN_FAIL unable to open message file example.msg for input: dummy reason
+FATAL [example.beta] LOG_BAD_SEVERITY unrecognized log severity: beta_fatal
+ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_error
+WARN  [example.beta] LOG_BAD_STREAM bad log console output stream: beta_warn
+INFO  [example.beta] LOG_READ_ERROR error reading from message file beta: info
 .
 ./logger_example -c stdout | cut -d' ' -f3- | diff $tempfile -
 passfail $?
 
 echo -n "2. Severity filter:"
 cat > $tempfile << .
-FATAL [example] MSG_WRITERR error writing to test1: 42
-ERROR [example] MSG_RDLOCMES reading local message file dummy/file
-FATAL [example.beta] MSG_BADSEVERITY unrecognized log severity: beta_fatal
-ERROR [example.beta] MSG_BADDESTINATION unrecognized log destination: beta_error
+FATAL [example] LOG_WRITE_ERROR error writing to test1: 42
+ERROR [example] LOG_READING_LOCAL_FILE reading local message file dummy/file
+FATAL [example.beta] LOG_BAD_SEVERITY unrecognized log severity: beta_fatal
+ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_error
 .
 ./logger_example -c stdout -s error | cut -d' ' -f3- | diff $tempfile -
 passfail $?
 
 echo -n "3. Debug level:"
 cat > $tempfile << .
-FATAL [example] MSG_WRITERR error writing to test1: 42
-ERROR [example] MSG_RDLOCMES reading local message file dummy/file
-WARN  [example] MSG_BADSTREAM bad log console output stream: example
-WARN  [example.alpha] MSG_READERR error reading from message file a.txt: dummy reason
-INFO  [example.alpha] MSG_OPENIN unable to open message file example.msg for input: dummy reason
-DEBUG [example] MSG_RDLOCMES reading local message file example/0
-DEBUG [example] MSG_RDLOCMES reading local message file example/24
-DEBUG [example] MSG_RDLOCMES reading local message file example/25
-FATAL [example.beta] MSG_BADSEVERITY unrecognized log severity: beta_fatal
-ERROR [example.beta] MSG_BADDESTINATION unrecognized log destination: beta_error
-WARN  [example.beta] MSG_BADSTREAM bad log console output stream: beta_warn
-INFO  [example.beta] MSG_READERR error reading from message file beta: info
-DEBUG [example.beta] MSG_BADSEVERITY unrecognized log severity: beta/25
+FATAL [example] LOG_WRITE_ERROR error writing to test1: 42
+ERROR [example] LOG_READING_LOCAL_FILE reading local message file dummy/file
+WARN  [example] LOG_BAD_STREAM bad log console output stream: example
+WARN  [example.alpha] LOG_READ_ERROR error reading from message file a.txt: dummy reason
+INFO  [example.alpha] LOG_INPUT_OPEN_FAIL unable to open message file example.msg for input: dummy reason
+DEBUG [example] LOG_READING_LOCAL_FILE reading local message file example/0
+DEBUG [example] LOG_READING_LOCAL_FILE reading local message file example/24
+DEBUG [example] LOG_READING_LOCAL_FILE reading local message file example/25
+FATAL [example.beta] LOG_BAD_SEVERITY unrecognized log severity: beta_fatal
+ERROR [example.beta] LOG_BAD_DESTINATION unrecognized log destination: beta_error
+WARN  [example.beta] LOG_BAD_STREAM bad log console output stream: beta_warn
+INFO  [example.beta] LOG_READ_ERROR error reading from message file beta: info
+DEBUG [example.beta] LOG_BAD_SEVERITY unrecognized log severity: beta/25
 .
 ./logger_example -c stdout -s debug -d 25 | cut -d' ' -f3- | diff $tempfile -
 passfail $?

+ 7 - 7
src/lib/nsas/Makefile.am

@@ -22,19 +22,19 @@ AM_CXXFLAGS += -Wno-unused-parameter
 endif
 
 # Define rule to build logging source files from message file
-nsasdef.h nsasdef.cc: nsasdef.mes
-	$(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/nsas/nsasdef.mes
+nsas_messages.h nsas_messages.cc: nsas_messages.mes
+	$(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/nsas/nsas_messages.mes
 
 # What is being built.
 lib_LTLIBRARIES = libnsas.la
 
-# Tell Automake that the nsasdef.{cc,h} source files are created in the build
+# Tell Automake that the nsas_messages.{cc,h} source files are created in the build
 # process, so it must create these before doing anything else.  Although they
 # are a dependency of the library (so will be created from the message file
 # anyway), there is no guarantee as to exactly _when_ in the build they will be
 # created.  As the .h file is included in other sources file (so must be
 # present when they are compiled), the safest option is to create it first.
-BUILT_SOURCES = nsasdef.h nsasdef.cc
+BUILT_SOURCES = nsas_messages.h nsas_messages.cc
 
 # Library sources. The generated files will not be in the distribution.
 libnsas_la_SOURCES  = address_entry.h address_entry.cc
@@ -54,10 +54,10 @@ libnsas_la_SOURCES += fetchable.h
 libnsas_la_SOURCES += address_request_callback.h
 libnsas_la_SOURCES += glue_hints.h glue_hints.cc
 
-nodist_libnsas_la_SOURCES  = nsasdef.h nsasdef.cc
+nodist_libnsas_la_SOURCES  = nsas_messages.h nsas_messages.cc
 
 # The message file should be in the distribution.
-EXTRA_DIST = nsasdef.mes
+EXTRA_DIST = nsas_messages.mes
 
 # Make sure that the generated files are got rid of in a clean operation
-CLEANFILES = *.gcno *.gcda nsasdef.h nsasdef.cc
+CLEANFILES = *.gcno *.gcda nsas_messages.h nsas_messages.cc

+ 2 - 3
src/lib/nsas/nameserver_address_store.cc

@@ -32,7 +32,6 @@
 #include "zone_entry.h"
 #include "glue_hints.h"
 #include "address_request_callback.h"
-#include "nsasdef.h"
 #include "nsas_log.h"
 
 using namespace isc::dns;
@@ -87,7 +86,7 @@ NameserverAddressStore::lookup(const string& zone, const RRClass& class_code,
     boost::shared_ptr<AddressRequestCallback> callback, AddressFamily family,
     const GlueHints& glue_hints)
 {
-    LOG_DEBUG(nsas_logger, NSAS_DBG_TRACE, NSAS_LOOKUPZONE).arg(zone);
+    LOG_DEBUG(nsas_logger, NSAS_DBG_TRACE, NSAS_SEARCH_ZONE_NS).arg(zone);
 
     pair<bool, boost::shared_ptr<ZoneEntry> > zone_obj(
         zone_hash_->getOrAdd(HashKey(zone, class_code),
@@ -108,7 +107,7 @@ NameserverAddressStore::cancel(const string& zone,
     const boost::shared_ptr<AddressRequestCallback>& callback,
     AddressFamily family)
 {
-    LOG_DEBUG(nsas_logger, NSAS_DBG_TRACE, NSAS_LOOKUPCANCEL).arg(zone);
+    LOG_DEBUG(nsas_logger, NSAS_DBG_TRACE, NSAS_LOOKUP_CANCEL).arg(zone);
 
     boost::shared_ptr<ZoneEntry> entry(zone_hash_->get(HashKey(zone,
                                                                class_code)));

+ 6 - 6
src/lib/nsas/nameserver_entry.cc

@@ -179,7 +179,7 @@ NameserverEntry::updateAddressRTTAtIndex(uint32_t rtt, size_t index,
         new_rtt = 1;
     }
     addresses_[family][index].setRTT(new_rtt);
-    LOG_DEBUG(nsas_logger, NSAS_DBG_RTT, NSAS_SETRTT)
+    LOG_DEBUG(nsas_logger, NSAS_DBG_RTT, NSAS_UPDATE_RTT)
               .arg(addresses_[family][index].getAddress().toText())
               .arg(old_rtt).arg(new_rtt);
 }
@@ -234,7 +234,7 @@ class NameserverEntry::ResolverCallback :
             if (!response_message ||
                 response_message->getRcode() != isc::dns::Rcode::NOERROR() ||
                 response_message->getRRCount(isc::dns::Message::SECTION_ANSWER) == 0) {
-                LOG_ERROR(nsas_logger, NSAS_INVRESPSTR).arg(entry_->getName());
+                LOG_ERROR(nsas_logger, NSAS_INVALID_RESPONSE).arg(entry_->getName());
                 failureInternal(lock);
                 return;
             }
@@ -249,7 +249,7 @@ class NameserverEntry::ResolverCallback :
                 response->getClass() != RRClass(entry_->getClass()))
             {
                 // Invalid response type or class
-                LOG_ERROR(nsas_logger, NSAS_INVRESPTC)
+                LOG_ERROR(nsas_logger, NSAS_WRONG_ANSWER)
                           .arg(entry_->getName()).arg(type_)
                           .arg(entry_->getClass()).arg(response->getType())
                           .arg(response->getClass());
@@ -276,7 +276,7 @@ class NameserverEntry::ResolverCallback :
                 // If we found it, use it. If not, create a new one.
                 entries.push_back(found ? *found : AddressEntry(
                                                    IOAddress(address), 1));
-                LOG_DEBUG(nsas_logger, NSAS_DBG_RESULTS, NSAS_NSLKUPSUCC)
+                LOG_DEBUG(nsas_logger, NSAS_DBG_RESULTS, NSAS_FOUND_ADDRESS)
                           .arg(address).arg(entry_->getName());
             }
 
@@ -322,7 +322,7 @@ class NameserverEntry::ResolverCallback :
          * So mark the current address family as unreachable.
          */
         virtual void failure() {
-            LOG_DEBUG(nsas_logger, NSAS_DBG_RESULTS, NSAS_NSLKUPFAIL)
+            LOG_DEBUG(nsas_logger, NSAS_DBG_RESULTS, NSAS_NS_LOOKUP_FAIL)
                       .arg(type_).arg(entry_->getName());
             Lock lock(entry_->mutex_);
             failureInternal(lock);
@@ -437,7 +437,7 @@ NameserverEntry::askIP(isc::resolve::ResolverInterface* resolver,
         // We are unlocked here, as the callback from that might want to lock
         lock.unlock();
 
-        LOG_DEBUG(nsas_logger, NSAS_DBG_TRACE, NSAS_NSADDR).arg(getName());
+        LOG_DEBUG(nsas_logger, NSAS_DBG_TRACE, NSAS_FIND_NS_ADDRESS).arg(getName());
         askIP(resolver, RRType::A(), V4_ONLY);
         askIP(resolver, RRType::AAAA(), V6_ONLY);
         // Make sure we end the routine when we are not locked

+ 1 - 1
src/lib/nsas/nsas_log.h

@@ -16,7 +16,7 @@
 #define __NSAS_LOG__H
 
 #include <log/macros.h>
-#include "nsasdef.h"
+#include "nsas_messages.h"
 
 namespace isc {
 namespace nsas {

+ 69 - 0
src/lib/nsas/nsas_messages.mes

@@ -0,0 +1,69 @@
+# Copyright (C) 2011  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.
+
+$NAMESPACE isc::nsas
+
+% NSAS_FIND_NS_ADDRESS asking resolver to obtain A and AAAA records for %1
+A debug message issued when the NSAS (nameserver address store - part
+of the resolver) is making a callback into the resolver to retrieve the
+address records for the specified nameserver.
+
+% NSAS_FOUND_ADDRESS found address %1 for %2
+A debug message issued when the NSAS (nameserver address store - part
+of the resolver) has retrieved the given address for the specified
+nameserver through an external query.
+
+% NSAS_INVALID_RESPONSE queried for %1 but got invalid response
+The NSAS (nameserver address store - part of the resolver) made a query
+for a RR for the specified nameserver but received an invalid response.
+Either the success function was called without a DNS message or the
+message was invalid on some way. (In the latter case, the error should
+have been picked up elsewhere in the processing logic, hence the raising
+of the error here.)
+
+This message indicates an internal error in the NSAS.  Please raise a
+bug report.
+
+% NSAS_LOOKUP_CANCEL lookup for zone %1 has been canceled
+A debug message issued when an NSAS (nameserver address store - part of
+the resolver) lookup for a zone has been canceled.
+
+% NSAS_NS_LOOKUP_FAIL failed to lookup any %1 for %2
+A debug message issued when the NSAS (nameserver address store - part of
+the resolver) has been unable to retrieve the specified resource record
+for the specified nameserver.  This is not necessarily a problem - the
+nameserver may be unreachable, in which case the NSAS will try other
+nameservers in the zone.
+
+% NSAS_SEARCH_ZONE_NS searching NSAS for nameservers for zone %1
+A debug message output when a call is made to the NSAS (nameserver 
+address store - part of the resolver) to obtain the nameservers for 
+the specified zone.
+
+% NSAS_UPDATE_RTT update RTT for %1: was %2 ms, is now %3 ms
+A NSAS (nameserver address store - part of the resolver) debug message
+reporting the update of a round-trip time (RTT) for a query made to the
+specified nameserver.  The RTT has been updated using the value given
+and the new RTT is displayed.  (The RTT is subject to a calculation that
+damps out sudden changes.  As a result, the new RTT used by the NSAS in
+future decisions of which nameserver to use is not necessarily equal to
+the RTT reported.)
+
+% NSAS_WRONG_ANSWER queried for %1 RR of type/class %2/%3, received response %4/%5
+A NSAS (nameserver address store - part of the resolver) made a query for
+a resource record of a particular type and class, but instead received
+an answer with a different given type and class.
+
+This message indicates an internal error in the NSAS.  Please raise a 
+bug report.

+ 0 - 61
src/lib/nsas/nsasdef.mes

@@ -1,61 +0,0 @@
-# Copyright (C) 2011  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.
-
-$PREFIX NSAS_
-$NAMESPACE isc::nsas
-
-% INVRESPSTR      queried for %1 but got invalid response
-This message indicates an internal error in the nameserver address store
-component (NSAS) of the resolver.  The NSAS made a query for a RR for the
-specified nameserver but received an invalid response.  Either the success
-function was called without a DNS message or the message was invalid on some
-way. (In the latter case, the error should have been picked up elsewhere in
-the processing logic, hence the raising of the error here.)
-
-% INVRESPTC       queried for %1 RR of type/class %2/%3, received response %4/%5
-This message indicates an internal error in the nameserver address store
-component (NSAS) of the resolver.  The NSAS made a query for the given RR
-type and class, but instead received an answer with the given type and class.
-
-% LOOKUPCANCEL    lookup for zone %1 has been cancelled
-A debug message, this is output when a NSAS (nameserver address store -
-part of the resolver) lookup for a zone has been cancelled.
-
-% LOOKUPZONE      searching NSAS for nameservers for zone %1
-A debug message, this is output when a call is made to the nameserver address
-store (part of the resolver) to obtain the nameservers for the specified zone.
-
-% NSADDR          asking resolver to obtain A and AAAA records for %1
-A debug message, the NSAS (nameserver address store - part of the resolver) is
-making a callback into the resolver to retrieve the address records for the
-specified nameserver.
-
-% NSLKUPFAIL      failed to lookup any %1 for %2
-A debug message, the NSAS (nameserver address store - part of the resolver)
-has been unable to retrieve the specified resource record for the specified
-nameserver.  This is not necessarily a problem - the nameserver may be
-unreachable, in which case the NSAS will try other nameservers in the zone.
-
-% NSLKUPSUCC      found address %1 for %2
-A debug message, the NSAS (nameserver address store - part of the resolver)
-has retrieved the given address for the specified nameserver through an
-external query.
-
-% SETRTT          reporting RTT for %1 as %2; new value is now %3
-A NSAS (nameserver address store - part of the resolver) debug message
-reporting the round-trip time (RTT) for a query made to the specified
-nameserver.  The RTT has been updated using the value given and the new RTT is
-displayed.  (The RTT is subject to a calculation that damps out sudden
-changes.  As a result, the new RTT is not necessarily equal to the RTT
-reported.)

+ 9 - 0
src/lib/python/isc/config/Makefile.am

@@ -1,10 +1,19 @@
 SUBDIRS = . tests
 
 python_PYTHON = __init__.py ccsession.py cfgmgr.py config_data.py module_spec.py
+pyexec_DATA = cfgmgr_messages.py
 
 pythondir = $(pyexecdir)/isc/config
 
+# Define rule to build logging source files from message file
+cfgmgr_messages.py: cfgmgr_messages.mes
+	$(top_builddir)/src/lib/log/compiler/message -p $(top_srcdir)/src/lib/python/isc/config/cfgmgr_messages.mes
+
+CLEANFILES = cfgmgr_messages.py cfgmgr_messages.pyc
+
 CLEANDIRS = __pycache__
 
+EXTRA_DIST = cfgmgr_messages.mes
+
 clean-local:
 	rm -rf $(CLEANDIRS)

+ 27 - 9
src/lib/python/isc/config/cfgmgr.py

@@ -28,7 +28,13 @@ import tempfile
 import json
 import errno
 from isc.cc import data
-from isc.config import ccsession, config_data
+from isc.config import ccsession, config_data, module_spec
+from isc.util.file import path_search
+import bind10_config
+import isc.log
+from cfgmgr_messages import *
+
+logger = isc.log.Logger("cfgmgr")
 
 class ConfigManagerDataReadError(Exception):
     """This exception is thrown when there is an error while reading
@@ -89,7 +95,7 @@ class ConfigManagerData:
                 elif file_config['version'] == 1:
                     # only format change, no other changes necessary
                     file_config['version'] = 2
-                    print("[b10-cfgmgr] Updating configuration database version from 1 to 2")
+                    logger.info(CFGMGR_AUTOMATIC_CONFIG_DATABASE_UPDATE, 1, 2)
                     config.data = file_config
                 else:
                     if config_data.BIND10_CONFIG_DATA_VERSION > file_config['version']:
@@ -131,12 +137,9 @@ class ConfigManagerData:
             else:
                 os.rename(filename, self.db_filename)
         except IOError as ioe:
-            # TODO: log this (level critical)
-            print("[b10-cfgmgr] Unable to write configuration file; configuration not stored: " + str(ioe))
-            # TODO: debug option to keep file?
+            logger.error(CFGMGR_IOERROR_WHILE_WRITING_CONFIGURATION, ioe)
         except OSError as ose:
-            # TODO: log this (level critical)
-            print("[b10-cfgmgr] Unable to write configuration file; configuration not stored: " + str(ose))
+            logger.error(CFGMGR_OSERROR_WHILE_WRITING_CONFIGURATION, ose)
         try:
             if filename and os.path.exists(filename):
                 os.remove(filename)
@@ -182,6 +185,20 @@ class ConfigManager:
         self.cc.group_subscribe("ConfigManager")
         self.cc.group_subscribe("Boss", "ConfigManager")
         self.running = False
+        # As a core module, CfgMgr is different than other modules,
+        # as it does not use a ModuleCCSession, and hence needs
+        # to handle logging config on its own
+        self.log_config_data = config_data.ConfigData(
+            isc.config.module_spec_from_file(
+                path_search('logging.spec',
+                bind10_config.PLUGIN_PATHS)))
+        # store the logging 'module' name for easier reference
+        self.log_module_name = self.log_config_data.get_module_spec().get_module_name()
+
+    def check_logging_config(self, config):
+        if self.log_module_name in config:
+            ccsession.default_logconfig_handler(config[self.log_module_name],
+                                                self.log_config_data)
 
     def notify_boss(self):
         """Notifies the Boss module that the Config Manager is running"""
@@ -256,6 +273,7 @@ class ConfigManager:
             self.config = ConfigManagerData.read_from_file(self.data_path,
                                                            self.\
                                                            database_filename)
+            self.check_logging_config(self.config.data);
         except ConfigManagerDataEmpty:
             # ok, just start with an empty config
             self.config = ConfigManagerData(self.data_path,
@@ -388,6 +406,8 @@ class ConfigManager:
                         got_error = True
                         err_list.append(val)
         if not got_error:
+            # if Logging config is in there, update our config as well
+            self.check_logging_config(cmd);
             self.write_config()
             return ccsession.create_answer(0)
         else:
@@ -441,8 +461,6 @@ class ConfigManager:
             elif cmd == ccsession.COMMAND_SET_CONFIG:
                 answer = self._handle_set_config(arg)
             elif cmd == ccsession.COMMAND_SHUTDOWN:
-                # TODO: logging
-                #print("[b10-cfgmgr] Received shutdown command")
                 self.running = False
                 answer = ccsession.create_answer(0)
             elif cmd == ccsession.COMMAND_MODULE_SPEC:

+ 50 - 0
src/lib/python/isc/config/cfgmgr_messages.mes

@@ -0,0 +1,50 @@
+# Copyright (C) 2011  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.
+
+# No namespace declaration - these constants go in the global namespace
+# of the xfrin messages python module.
+
+% CFGMGR_AUTOMATIC_CONFIG_DATABASE_UPDATE Updating configuration database from version %1 to %2
+An older version of the configuration database has been found, from which
+there was an automatic upgrade path to the current version. These changes
+are now applied, and no action from the administrator is necessary.
+
+% CFGMGR_CC_SESSION_ERROR Error connecting to command channel: %1
+The configuration manager daemon was unable to connect to the messaging
+system. The most likely cause is that msgq is not running.
+
+% CFGMGR_DATA_READ_ERROR error reading configuration database from disk: %1
+There was a problem reading the persistent configuration data as stored
+on disk. The file may be corrupted, or it is of a version from where
+there is no automatic upgrade path. The file needs to be repaired or
+removed. The configuration manager daemon will now shut down.
+
+% CFGMGR_IOERROR_WHILE_WRITING_CONFIGURATION Unable to write configuration file; configuration not stored: %1
+There was an IO error from the system while the configuration manager
+was trying to write the configuration database to disk. The specific
+error is given. The most likely cause is that the directory where
+the file is stored does not exist, or is not writable. The updated
+configuration is not stored.
+
+% CFGMGR_OSERROR_WHILE_WRITING_CONFIGURATION Unable to write configuration file; configuration not stored: %1
+There was an OS error from the system while the configuration manager
+was trying to write the configuration database to disk. The specific
+error is given. The most likely cause is that the system does not have
+write access to the configuration database file. The updated
+configuration is not stored.
+
+% CFGMGR_STOPPED_BY_KEYBOARD keyboard interrupt, shutting down
+There was a keyboard interrupt signal to stop the cfgmgr daemon. The
+daemon will now shut down.
+

+ 1 - 1
src/lib/python/isc/config/tests/Makefile.am

@@ -21,7 +21,7 @@ endif
 	for pytest in $(PYTESTS) ; do \
 	echo Running test: $$pytest ; \
 	$(LIBRARY_PATH_PLACEHOLDER) \
-	env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python \
+	env PYTHONPATH=$(abs_top_srcdir)/src/lib/python:$(abs_top_builddir)/src/lib/python:$(abs_top_builddir)/src/lib/python/isc/config \
 	B10_TEST_PLUGIN_DIR=$(abs_top_srcdir)/src/bin/cfgmgr/plugins \
 	CONFIG_TESTDATA_PATH=$(abs_top_srcdir)/src/lib/config/tests/testdata \
 	CONFIG_WR_TESTDATA_PATH=$(abs_top_builddir)/src/lib/config/tests/testdata \

+ 6 - 6
src/lib/resolve/Makefile.am

@@ -8,8 +8,8 @@ AM_CPPFLAGS += $(SQLITE_CFLAGS)
 AM_CXXFLAGS = $(B10_CXXFLAGS)
 
 # Define rule to build logging source files from message file
-resolvedef.h resolvedef.cc: resolvedef.mes
-	$(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/resolve/resolvedef.mes
+resolve_messages.h resolve_messages.cc: resolve_messages.mes
+	$(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/resolve/resolve_messages.mes
 
 # Tell Automake that the nsasdef.{cc,h} source files are created in the build
 # process, so it must create these before doing anything else.  Although they
@@ -17,9 +17,9 @@ resolvedef.h resolvedef.cc: resolvedef.mes
 # anyway), there is no guarantee as to exactly _when_ in the build they will be
 # created.  As the .h file is included in other sources file (so must be
 # present when they are compiled), the safest option is to create it first.
-BUILT_SOURCES = resolvedef.h resolvedef.cc
+BUILT_SOURCES = resolve_messages.h resolve_messages.cc
 
-CLEANFILES = *.gcno *.gcda resolvedef.cc resolvedef.h
+CLEANFILES = *.gcno *.gcda resolve_messages.cc resolve_messages.h
 
 lib_LTLIBRARIES = libresolve.la
 libresolve_la_SOURCES = resolve.h resolve.cc
@@ -29,14 +29,14 @@ libresolve_la_SOURCES += resolver_callback.h resolver_callback.cc
 libresolve_la_SOURCES += response_classifier.cc response_classifier.h
 libresolve_la_SOURCES += recursive_query.cc recursive_query.h
 
-nodist_libresolve_la_SOURCES = resolvedef.h resolvedef.cc
+nodist_libresolve_la_SOURCES = resolve_messages.h resolve_messages.cc
 
 libresolve_la_LIBADD = $(top_builddir)/src/lib/dns/libdns++.la
 libresolve_la_LIBADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
 libresolve_la_LIBADD += $(top_builddir)/src/lib/log/liblog.la
 
 # The message file should be in the distribution.
-EXTRA_DIST = resolvedef.mes
+EXTRA_DIST = resolve_messages.mes
 
 # Note: the ordering matters: -Wno-... must follow -Wextra (defined in
 # B10_CXXFLAGS)

+ 21 - 21
src/lib/resolve/recursive_query.cc

@@ -147,7 +147,7 @@ RecursiveQuery::RecursiveQuery(DNSService& dns_service,
 // Set the test server - only used for unit testing.
 void
 RecursiveQuery::setTestServer(const std::string& address, uint16_t port) {
-    LOG_WARN(isc::resolve::logger, RESLIB_TESTSERV).arg(address).arg(port);
+    LOG_WARN(isc::resolve::logger, RESLIB_TEST_SERVER).arg(address).arg(port);
     test_server_.first = address;
     test_server_.second = port;
 }
@@ -177,7 +177,7 @@ public:
     
     void success(const isc::nsas::NameserverAddress& address) {
         // Success callback, send query to found namesever
-        LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CB, RESLIB_RUNQUSUCC)
+        LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CB, RESLIB_RUNQ_SUCCESS)
                   .arg(address.getAddress().toText());
         rq_->nsasCallbackCalled();
         rq_->sendTo(address);
@@ -185,7 +185,7 @@ public:
     
     void unreachable() {
         // Nameservers unreachable: drop query or send servfail?
-        LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CB, RESLIB_RUNQUFAIL);
+        LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CB, RESLIB_RUNQ_FAIL);
         rq_->nsasCallbackCalled();
         rq_->makeSERVFAIL();
         rq_->callCallback(true);
@@ -311,7 +311,7 @@ private:
     // if we have a response for our query stored already. if
     // so, call handlerecursiveresponse(), if not, we call send()
     void doLookup() {
-        LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CACHE, RESLIB_RUNCALOOK)
+        LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CACHE, RESLIB_RUNQ_CACHE_LOOKUP)
                   .arg(questionText(question_));
 
         Message cached_message(Message::RENDER);
@@ -319,7 +319,7 @@ private:
         if (cache_.lookup(question_.getName(), question_.getType(),
                           question_.getClass(), cached_message)) {
 
-            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CACHE, RESLIB_RUNCAFND)
+            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CACHE, RESLIB_RUNQ_CACHE_FIND)
                       .arg(questionText(question_));
             // Should these be set by the cache too?
             cached_message.setOpcode(Opcode::QUERY());
@@ -366,7 +366,7 @@ private:
         protocol_ = protocol;   // Store protocol being used for this
         if (test_server_.second != 0) {
             // Send query to test server
-            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_TRACE, RESLIB_TESTUPSTR)
+            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_TRACE, RESLIB_TEST_UPSTREAM)
                 .arg(questionText(question_)).arg(test_server_.first);
             gettimeofday(&current_ns_qsent_time, NULL);
             ++outstanding_events_;
@@ -379,7 +379,7 @@ private:
         } else {
             // Ask the NSAS for an address for the current zone,
             // the callback will call the actual sendTo()
-            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_TRACE, RESLIB_NSASLOOK)
+            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_TRACE, RESLIB_NSAS_LOOKUP)
                       .arg(cur_zone_);
 
             // Can we have multiple calls to nsas_out? Let's assume not
@@ -440,7 +440,7 @@ private:
             // is, we reset our 'current servers' to the root servers).
             if (cname_count_ >= RESOLVER_MAX_CNAME_CHAIN) {
                 // CNAME chain too long - just give up
-                LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS, RESLIB_LONGCHAIN)
+                LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS, RESLIB_LONG_CHAIN)
                           .arg(questionText(question_));
                 makeSERVFAIL();
                 return true;
@@ -456,7 +456,7 @@ private:
                                  question_.getType());
 
             // Follow CNAME chain.
-            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS, RESLIB_FOLLOWCNAME)
+            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS, RESLIB_FOLLOW_CNAME)
                       .arg(questionText(question_));
             doLookup();
             return false;
@@ -465,7 +465,7 @@ private:
         case isc::resolve::ResponseClassifier::NXDOMAIN:
         case isc::resolve::ResponseClassifier::NXRRSET:
             // Received NXDOMAIN or NXRRSET, just copy and return
-            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS, RESLIB_NXDOMRR)
+            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS, RESLIB_NXDOM_NXRR)
                       .arg(questionText(question_));
             isc::resolve::copyResponseMessage(incoming, answer_message_);
             // no negcache yet
@@ -496,7 +496,7 @@ private:
                         // (this requires a few API changes in related
                         // libraries, so as not to need many conversions)
                         cur_zone_ = rrs->getName().toText();
-                        LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS, RESLIB_REFERZONE)
+                        LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS, RESLIB_REFER_ZONE)
                                   .arg(cur_zone_);
                         found_ns = true;
                         break;
@@ -522,7 +522,7 @@ private:
                 return false;
             } else {
                 // Referral was received but did not contain an NS RRset.
-                LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS, RESLIB_NONSRRSET)
+                LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS, RESLIB_NO_NS_RRSET)
                           .arg(questionText(question_));
 
                 // TODO this will result in answering with the delegation. oh well
@@ -554,7 +554,7 @@ private:
         case isc::resolve::ResponseClassifier::NOTSINGLE:
         case isc::resolve::ResponseClassifier::OPCODE:
         case isc::resolve::ResponseClassifier::RCODE:
-            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS, RESLIB_RCODERR)
+            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS, RESLIB_RCODE_ERR)
                       .arg(questionText(question_));
             // Should we try a different server rather than SERVFAIL?
             makeSERVFAIL();
@@ -751,7 +751,7 @@ public:
                 if (retries_--) {
                     // Retry
                     LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS,
-                              RESLIB_PROTOCOLRTRY)
+                              RESLIB_PROTOCOL_RETRY)
                               .arg(questionText(question_)).arg(dpe.what())
                               .arg(retries_);
                     send();
@@ -769,7 +769,7 @@ public:
             }
         } else if (!done_ && retries_--) {
             // Query timed out, but we have some retries, so send again
-            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS, RESLIB_TIMEOUTRTRY)
+            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_RESULTS, RESLIB_TIMEOUT_RETRY)
                       .arg(questionText(question_))
                       .arg(current_ns_address.getAddress().toText()).arg(retries_);
             current_ns_address.updateRTT(isc::nsas::AddressEntry::UNREACHABLE);
@@ -993,7 +993,7 @@ RecursiveQuery::resolve(const QuestionPtr& question,
                       question->getClass(), *answer_message) &&
         answer_message->getRRCount(Message::SECTION_ANSWER) > 0) {
         // Message found, return that
-        LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CACHE, RESLIB_RESCAFND)
+        LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CACHE, RESLIB_RECQ_CACHE_FIND)
                   .arg(questionText(*question)).arg(1);
         
         // TODO: err, should cache set rcode as well?
@@ -1007,7 +1007,7 @@ RecursiveQuery::resolve(const QuestionPtr& question,
                                               question->getClass());
         if (cached_rrset) {
             // Found single RRset in cache
-            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CACHE, RESLIB_RRSETFND)
+            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CACHE, RESLIB_RRSET_FOUND)
                       .arg(questionText(*question)).arg(1);
             answer_message->addRRset(Message::SECTION_ANSWER,
                                      cached_rrset);
@@ -1016,7 +1016,7 @@ RecursiveQuery::resolve(const QuestionPtr& question,
         } else {
             // Message not found in cache, start recursive query.  It will
             // delete itself when it is done
-            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_TRACE, RESLIB_RESCANOTFND)
+            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_TRACE, RESLIB_RECQ_CACHE_NO_FIND)
                       .arg(questionText(*question)).arg(1);
             new RunningQuery(io, *question, answer_message,
                              test_server_, buffer, callback,
@@ -1055,7 +1055,7 @@ RecursiveQuery::resolve(const Question& question,
         answer_message->getRRCount(Message::SECTION_ANSWER) > 0) {
 
         // Message found, return that
-        LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CACHE, RESLIB_RESCAFND)
+        LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CACHE, RESLIB_RECQ_CACHE_FIND)
                   .arg(questionText(question)).arg(2);
         // TODO: err, should cache set rcode as well?
         answer_message->setRcode(Rcode::NOERROR());
@@ -1068,7 +1068,7 @@ RecursiveQuery::resolve(const Question& question,
                                               question.getClass());
         if (cached_rrset) {
             // Found single RRset in cache
-            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CACHE, RESLIB_RRSETFND)
+            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_CACHE, RESLIB_RRSET_FOUND)
                       .arg(questionText(question)).arg(2);
             answer_message->addRRset(Message::SECTION_ANSWER,
                                      cached_rrset);
@@ -1078,7 +1078,7 @@ RecursiveQuery::resolve(const Question& question,
         } else {
             // Message not found in cache, start recursive query.  It will
             // delete itself when it is done
-            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_TRACE, RESLIB_RESCANOTFND)
+            LOG_DEBUG(isc::resolve::logger, RESLIB_DBG_TRACE, RESLIB_RECQ_CACHE_NO_FIND)
                       .arg(questionText(question)).arg(2);
             new RunningQuery(io, question, answer_message, 
                              test_server_, buffer, crs, query_timeout_,

+ 1 - 1
src/lib/resolve/resolve_log.h

@@ -16,7 +16,7 @@
 #define __RESOLVE_LOG__H
 
 #include <log/macros.h>
-#include "resolvedef.h"
+#include "resolve_messages.h"
 
 namespace isc {
 namespace resolve {

+ 36 - 37
src/lib/resolve/resolvedef.mes

@@ -12,144 +12,143 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-$PREFIX RESLIB_
 $NAMESPACE isc::resolve
 
-% ANSWER        answer received in response to query for <%1>
+% RESLIB_ANSWER answer received in response to query for <%1>
 A debug message recording that an answer has been received to an upstream
 query for the specified question.  Previous debug messages will have indicated
 the server to which the question was sent.
 
-% CNAME         CNAME received in response to query for <%1>
+% RESLIB_CNAME CNAME received in response to query for <%1>
 A debug message recording that CNAME response has been received to an upstream
 query for the specified question.  Previous debug messages will have indicated
 the server to which the question was sent.
 
-% DEEPEST       did not find <%1> in cache, deepest delegation found is %2
+% RESLIB_DEEPEST did not find <%1> in cache, deepest delegation found is %2
 A debug message, a cache lookup did not find the specified <name, class,
 type> tuple in the cache; instead, the deepest delegation found is indicated.
 
-% FOLLOWCNAME   following CNAME chain to <%1>
+% RESLIB_FOLLOW_CNAME following CNAME chain to <%1>
 A debug message, a CNAME response was received and another query is being issued
 for the <name, class, type> tuple.
 
-% LONGCHAIN     CNAME received in response to query for <%1>: CNAME chain length exceeded
+% RESLIB_LONG_CHAIN CNAME received in response to query for <%1>: CNAME chain length exceeded
 A debug message recording that a CNAME response has been received to an upstream
 query for the specified question (Previous debug messages will have indicated
 the server to which the question was sent).  However, receipt of this CNAME
 has meant that the resolver has exceeded the CNAME chain limit (a CNAME chain
 is where on CNAME points to another) and so an error is being returned.
 
-% NONSRRSET     no NS RRSet in referral response received to query for <%1>
+% RESLIB_NO_NS_RRSET no NS RRSet in referral response received to query for <%1>
 A debug message, this indicates that a response was received for the specified
-query and was categorised as a referral.  However, the received message did
+query and was categorized as a referral.  However, the received message did
 not contain any NS RRsets.  This may indicate a programming error in the
 response classification code.
 
-% NSASLOOK      looking up nameserver for zone %1 in the NSAS
+% RESLIB_NSAS_LOOKUP looking up nameserver for zone %1 in the NSAS
 A debug message, the RunningQuery object is querying the NSAS for the
 nameservers for the specified zone.
 
-% NXDOMRR       NXDOMAIN/NXRRSET received in response to query for <%1>
+% RESLIB_NXDOM_NXRR NXDOMAIN/NXRRSET received in response to query for <%1>
 A debug message recording that either a NXDOMAIN or an NXRRSET response has
 been received to an upstream query for the specified question.  Previous debug
 messages will have indicated the server to which the question was sent.
 
-% PROTOCOL      protocol error in answer for %1:  %3
+% RESLIB_PROTOCOL protocol error in answer for %1:  %3
 A debug message indicating that a protocol error was received.  As there
 are no retries left, an error will be reported.
 
-% PROTOCOLRTRY  protocol error in answer for %1: %2 (retries left: %3)
+% RESLIB_PROTOCOL_RETRY protocol error in answer for %1: %2 (retries left: %3)
 A debug message indicating that a protocol error was received and that
 the resolver is repeating the query to the same nameserver.  After this
 repeated query, there will be the indicated number of retries left.
 
-% RCODERR       RCODE indicates error in response to query for <%1>
+% RESLIB_RCODE_ERR RCODE indicates error in response to query for <%1>
 A debug message, the response to the specified query indicated an error
 that is not covered by a specific code path.  A SERVFAIL will be returned.
 
-% REFERRAL      referral received in response to query for <%1>
-A debug message recording that a referral response has been received to an
-upstream query for the specified question.  Previous debug messages will
-have indicated the server to which the question was sent.
-
-% REFERZONE     referred to zone %1
-A debug message indicating that the last referral message was to the specified
-zone.
-
-% RESCAFND      found <%1> in the cache (resolve() instance %2)
+% RESLIB_RECQ_CACHE_FIND found <%1> in the cache (resolve() instance %2)
 This is a debug message and indicates that a RecursiveQuery object found the
 the specified <name, class, type> tuple in the cache.  The instance number
 at the end of the message indicates which of the two resolve() methods has
 been called.
 
-% RESCANOTFND   did not find <%1> in the cache, starting RunningQuery (resolve() instance %2)
+% RESLIB_RECQ_CACHE_NO_FIND did not find <%1> in the cache, starting RunningQuery (resolve() instance %2)
 This is a debug message and indicates that the look in the cache made by the
 RecursiveQuery::resolve() method did not find an answer, so a new RunningQuery
 object has been created to resolve the question.  The instance number at
 the end of the message indicates which of the two resolve() methods has
 been called.
 
-% RESOLVE       asked to resolve <%1> (resolve() instance %2)
+% RESLIB_REFERRAL referral received in response to query for <%1>
+A debug message recording that a referral response has been received to an
+upstream query for the specified question.  Previous debug messages will
+have indicated the server to which the question was sent.
+
+% RESLIB_REFER_ZONE referred to zone %1
+A debug message indicating that the last referral message was to the specified
+zone.
+
+% RESLIB_RESOLVE asked to resolve <%1> (resolve() instance %2)
 A debug message, the RecursiveQuery::resolve method has been called to resolve
 the specified <name, class, type> tuple.  The first action will be to lookup
 the specified tuple in the cache.  The instance number at the end of the
 message indicates which of the two resolve() methods has been called.
 
-% RRSETFND      found single RRset in the cache when querying for <%1> (resolve() instance %2)
+% RESLIB_RRSET_FOUND found single RRset in the cache when querying for <%1> (resolve() instance %2)
 A debug message, indicating that when RecursiveQuery::resolve queried the
 cache, a single RRset was found which was put in the answer.  The instance
 number at the end of the message indicates which of the two resolve()
 methods has been called.
 
-% RTT           round-trip time of last query calculated as %1 ms
+% RESLIB_RTT round-trip time of last query calculated as %1 ms
 A debug message giving the round-trip time of the last query and response.
 
-% RUNCAFND      found <%1> in the cache
+% RESLIB_RUNQ_CACHE_FIND found <%1> in the cache
 This is a debug message and indicates that a RunningQuery object found
 the specified <name, class, type> tuple in the cache.
 
-% RUNCALOOK     looking up up <%1> in the cache
+% RESLIB_RUNQ_CACHE_LOOKUP looking up up <%1> in the cache
 This is a debug message and indicates that a RunningQuery object has made
 a call to its doLookup() method to look up the specified <name, class, type>
 tuple, the first action of which will be to examine the cache.
 
-% RUNQUFAIL     failure callback - nameservers are unreachable
+% RESLIB_RUNQ_FAIL failure callback - nameservers are unreachable
 A debug message indicating that a RunningQuery's failure callback has been
 called because all nameservers for the zone in question are unreachable.
 
-% RUNQUSUCC     success callback - sending query to %1
+% RESLIB_RUNQ_SUCCESS success callback - sending query to %1
 A debug message indicating that a RunningQuery's success callback has been
 called because a nameserver has been found, and that a query is being sent
 to the specified nameserver.
 
-% TESTSERV      setting test server to %1(%2)
+% RESLIB_TEST_SERVER setting test server to %1(%2)
 This is an internal debugging message and is only generated in unit tests.
 It indicates that all upstream queries from the resolver are being routed to
 the specified server, regardless of the address of the nameserver to which
 the query would normally be routed.  As it should never be seen in normal
 operation, it is a warning message instead of a debug message.
 
-% TESTUPSTR     sending upstream query for <%1> to test server at %2
+% RESLIB_TEST_UPSTREAM sending upstream query for <%1> to test server at %2
 This is a debug message and should only be seen in unit tests.  A query for
 the specified <name, class, type> tuple is being sent to a test nameserver
 whose address is given in the message.
 
-% TIMEOUT       query <%1> to %2 timed out
+% RESLIB_TIMEOUT query <%1> to %2 timed out
 A debug message indicating that the specified query has timed out and as
 there are no retries left, an error will be reported.
 
-% TIMEOUTRTRY   query <%1> to %2 timed out, re-trying (retries left: %3)
+% RESLIB_TIMEOUT_RETRY query <%1> to %2 timed out, re-trying (retries left: %3)
 A debug message indicating that the specified query has timed out and that
 the resolver is repeating the query to the same nameserver.  After this
 repeated query, there will be the indicated number of retries left.
 
-% TRUNCATED     response to query for <%1> was truncated, re-querying over TCP
+% RESLIB_TRUNCATED response to query for <%1> was truncated, re-querying over TCP
 A debug message, this indicates that the response to the specified query was
 truncated and that the resolver will be re-querying over TCP.  There are
 various reasons why responses may be truncated, so this message is normal and
 gives no cause for concern.
 
-% UPSTREAM      sending upstream query for <%1> to %2
+% RESLIB_UPSTREAM sending upstream query for <%1> to %2
 A debug message indicating that a query for the specified <name, class, type>
 tuple is being sent to a nameserver whose address is given in the message.

+ 2 - 0
src/lib/server_common/tests/Makefile.am

@@ -38,6 +38,8 @@ run_unittests_LDADD += $(top_builddir)/src/lib/server_common/libserver_common.la
 run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
 run_unittests_LDADD += $(top_builddir)/src/lib/asiodns/libasiodns.la
 run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
+run_unittests_LDADD += $(top_builddir)/src/lib/acl/libacl.la
+run_unittests_LDADD += $(top_builddir)/src/lib/util/libutil.la
 run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
 run_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
 run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la