Browse Source

[1924] Create a file for common protocol constants

This should be included and used from whatever libraries and programs
that talk to other bind10 programs. It allows defining constants shared
across the protocol.
Michal 'vorner' Vaner 12 years ago
parent
commit
8ea6b0f1c2
3 changed files with 77 additions and 0 deletions
  1. 1 0
      src/lib/util/Makefile.am
  2. 34 0
      src/lib/util/common_defs.cc
  3. 42 0
      src/lib/util/common_defs.h

+ 1 - 0
src/lib/util/Makefile.am

@@ -19,6 +19,7 @@ libb10_util_la_SOURCES += interprocess_sync_null.h interprocess_sync_null.cc
 libb10_util_la_SOURCES += memory_segment.h
 libb10_util_la_SOURCES += memory_segment_local.h memory_segment_local.cc
 libb10_util_la_SOURCES += range_utilities.h
+libb10_util_la_SOURCES += common_defs.h common_defs.cc
 libb10_util_la_SOURCES += hash/sha1.h hash/sha1.cc
 libb10_util_la_SOURCES += encode/base16_from_binary.h
 libb10_util_la_SOURCES += encode/base32hex.h encode/base64.h

+ 34 - 0
src/lib/util/common_defs.cc

@@ -0,0 +1,34 @@
+// Copyright (C) 2013  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 <util/common_defs.h>
+
+namespace isc {
+namespace util {
+
+// Aside from defining the values for the C++ util library, this file is also
+// used as direct input of the generator of the python counterpart. Please,
+// keep the syntax here simple and check the generated file
+// (lib/python/isc/util/common_defs.py) is correct and sane.
+
+const char* CC_HEADER_TYPE = "type";
+const char* CC_HEADER_FROM = "from";
+const char* CC_HEADER_TO = "to";
+const char* CC_HEADER_GROUP = "group";
+const char* CC_HEADER_INSTANCE = "instance";
+const char* CC_HEADER_SEQ = "seq";
+const char* CC_HEADER_WANT_ANSWER = "want_answer";
+
+}
+}

+ 42 - 0
src/lib/util/common_defs.h

@@ -0,0 +1,42 @@
+// Copyright (C) 2013  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.
+
+#ifndef BIND10_COMMON_DEFS_H
+#define BIND10_COMMON_DEFS_H
+
+namespace isc {
+namespace util {
+
+// \file common_defs.h
+// \brief Common constant definitions.
+//
+// This file contains common definitions of constasts used across the sources.
+// It includes, but is not limited to the definitions of messages sent from
+// one process to another. Since the names should be self-explanatory and
+// the variables here are used mostly to synchronize the same values across
+// multiple programs, separate documentation for each variable is not provided.
+
+// Constants used in the CC protocol (sent through MSGQ)
+extern const char* CC_HEADER_TYPE;
+extern const char* CC_HEADER_FROM;
+extern const char* CC_HEADER_TO;
+extern const char* CC_HEADER_GROUP;
+extern const char* CC_HEADER_INSTANCE;
+extern const char* CC_HEADER_SEQ;
+extern const char* CC_HEADER_WANT_ANSWER;
+
+}
+}
+
+#endif