Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-4]: src/dist/bind/lib/isc Pull up revision 1.1 (new) (requested...



details:   https://anonhg.NetBSD.org/src/rev/94d876c2a492
branches:  netbsd-1-4
changeset: 469801:94d876c2a492
user:      he <he%NetBSD.org@localhost>
date:      Sat Dec 04 17:05:40 1999 +0000

description:
Pull up revision 1.1 (new) (requested by christos and veego):
  Update to BIND 8.2.2-P5.

diffstat:

 dist/bind/lib/isc/ctl_p.c |  158 ++++++++++++++++++++++++++++++++++++++++++++++
 dist/bind/lib/isc/ctl_p.h |   24 ++++++
 2 files changed, 182 insertions(+), 0 deletions(-)

diffs (190 lines):

diff -r 7ce1ffa36f14 -r 94d876c2a492 dist/bind/lib/isc/ctl_p.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/dist/bind/lib/isc/ctl_p.c Sat Dec 04 17:05:40 1999 +0000
@@ -0,0 +1,158 @@
+/*     $NetBSD: ctl_p.c,v 1.1.1.1.2.2 1999/12/04 17:05:40 he Exp $     */
+
+#if !defined(lint) && !defined(SABER)
+static const char rcsid[] = "Id: ctl_p.c,v 8.6 1999/10/13 16:39:34 vixie Exp";
+#endif /* not lint */
+
+/*
+ * Copyright (c) 1998,1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+/* Extern. */
+
+#include "port_before.h"
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <arpa/inet.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include <isc/assertions.h>
+#include <isc/eventlib.h>
+#include <isc/logging.h>
+#include <isc/memcluster.h>
+#include <isc/ctl.h>
+
+#include "ctl_p.h"
+
+#include "port_after.h"
+
+/* Constants. */
+
+const char * const ctl_sevnames[] = {
+       "debug", "warning", "error"
+};
+
+/* Public. */
+
+/*
+ * ctl_logger()
+ *     if ctl_startup()'s caller didn't specify a logger, this one
+ *     is used.  this pollutes stderr with all kinds of trash so it will
+ *     probably never be used in real applications.
+ */
+void
+ctl_logger(enum ctl_severity severity, const char *format, ...) {
+       va_list ap;
+       static const char me[] = "ctl_logger";
+
+       fprintf(stderr, "%s(%s): ", me, ctl_sevnames[severity]);
+       va_start(ap, format);
+       vfprintf(stderr, format, ap);
+       va_end(ap);
+       fputc('\n', stderr);
+}
+
+int
+ctl_bufget(struct ctl_buf *buf, ctl_logfunc logger) {
+       static const char me[] = "ctl_bufget";
+
+       REQUIRE(!allocated_p(*buf) && buf->used == 0);
+       buf->text = memget(MAX_LINELEN);
+       if (!allocated_p(*buf)) {
+               (*logger)(ctl_error, "%s: getmem: %s", me, strerror(errno));
+               return (-1);
+       }
+       buf->used = 0;
+       return (0);
+}
+
+void
+ctl_bufput(struct ctl_buf *buf) {
+
+       REQUIRE(allocated_p(*buf));
+       memput(buf->text, MAX_LINELEN);
+       buf->text = NULL;
+       buf->used = 0;
+}
+
+const char *
+ctl_sa_ntop(const struct sockaddr *sa,
+           char *buf, size_t size,
+           ctl_logfunc logger)
+{
+       static const char me[] = "ctl_sa_ntop";
+       static const char punt[] = "[0].-1";
+       char tmp[sizeof "255.255.255.255"];
+
+       switch (sa->sa_family) {
+       case AF_INET: {
+               const struct sockaddr_in *in = (struct sockaddr_in *) sa;
+
+               if (inet_ntop(in->sin_family, &in->sin_addr, tmp, sizeof tmp)
+                   == NULL) {
+                       (*logger)(ctl_error, "%s: inet_ntop(%u %04x %08x): %s",
+                                 me, in->sin_family,
+                                 in->sin_port, in->sin_addr.s_addr,
+                                 strerror(errno));
+                       return (punt);
+               }
+               if (strlen(tmp) + sizeof "[].65535" > size) {
+                       (*logger)(ctl_error, "%s: buffer overflow", me);
+                       return (punt);
+               }
+               (void) sprintf(buf, "[%s].%u", tmp, ntohs(in->sin_port));
+               return (buf);
+           }
+       case AF_UNIX: {
+               const struct sockaddr_un *un = (struct sockaddr_un *) sa;
+               int x = sizeof un->sun_path;
+
+               if (x > size)
+                       x = size;
+               strncpy(buf, un->sun_path, x - 1);
+               buf[x - 1] = '\0';
+               return (buf);
+           }
+       default:
+               return (punt);
+       }
+}
+
+void
+ctl_sa_copy(const struct sockaddr *src, struct sockaddr *dst) {
+       switch (src->sa_family) {
+       case AF_INET:
+               *((struct sockaddr_in *)dst) =  *((struct sockaddr_in *)src);
+               break;
+       case AF_UNIX:
+               *((struct sockaddr_un *)dst) =  *((struct sockaddr_un *)src);
+               break;
+       default:
+               *dst = *src;
+               break;
+       }
+}
diff -r 7ce1ffa36f14 -r 94d876c2a492 dist/bind/lib/isc/ctl_p.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/dist/bind/lib/isc/ctl_p.h Sat Dec 04 17:05:40 1999 +0000
@@ -0,0 +1,24 @@
+/*     $NetBSD: ctl_p.h,v 1.1.1.1.2.2 1999/12/04 17:05:43 he Exp $     */
+
+struct ctl_buf {
+       char *                  text;
+       size_t                  used;
+};
+
+#define        MAX_LINELEN             990     /* Like SMTP. */
+#define        MAX_NTOP                (sizeof "[255.255.255.255].65535")
+
+#define        allocated_p(Buf) ((Buf).text != NULL)
+#define        buffer_init(Buf) ((Buf).text = 0, (Buf.used) = 0)
+
+#define        ctl_bufget      __ctl_bufget
+#define        ctl_bufput      __ctl_bufput
+#define        ctl_sa_ntop     __ctl_sa_ntop
+#define        ctl_sa_copy     __ctl_sa_copy
+
+int                    ctl_bufget(struct ctl_buf *, ctl_logfunc);
+void                   ctl_bufput(struct ctl_buf *);
+const char *           ctl_sa_ntop(const struct sockaddr *, char *, size_t,
+                                   ctl_logfunc);
+void                   ctl_sa_copy(const struct sockaddr *,
+                                   struct sockaddr *);



Home | Main Index | Thread Index | Old Index