Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/blacklist/bin separate the dumpkey function and...



details:   https://anonhg.NetBSD.org/src/rev/3231e678569c
branches:  trunk
changeset: 335697:3231e678569c
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Jan 21 21:24:25 2015 +0000

description:
separate the dumpkey function and use it for the state printing too.

diffstat:

 external/bsd/blacklist/bin/state.c |  26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diffs (61 lines):

diff -r 605a97a3c9b5 -r 3231e678569c external/bsd/blacklist/bin/state.c
--- a/external/bsd/blacklist/bin/state.c        Wed Jan 21 19:45:26 2015 +0000
+++ b/external/bsd/blacklist/bin/state.c        Wed Jan 21 21:24:25 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: state.c,v 1.3 2015/01/21 16:16:00 christos Exp $       */
+/*     $NetBSD: state.c,v 1.4 2015/01/21 21:24:25 christos Exp $       */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: state.c,v 1.3 2015/01/21 16:16:00 christos Exp $");
+__RCSID("$NetBSD: state.c,v 1.4 2015/01/21 21:24:25 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -87,6 +87,17 @@
 };
 
 static void
+dumpkey(const struct dbkey *k)
+{
+       const unsigned char *p = (const void *)k;
+       const unsigned char *e = p + sizeof(*k);
+       printf("%s: ", __func__);
+       while (p < e)
+               printf("%.2x", *p++);
+       printf("\n");
+}
+
+static void
 makekey(struct dbkey *k, const struct sockaddr_storage *ss,
     const struct conf *c)
 {
@@ -105,14 +116,8 @@
                    k->ss.ss_family);
                break;
        }
-       if (debug) {
-               unsigned char *p = (void *)k;
-               unsigned char *e = p + sizeof(*k);
-               printf("%s: ", __func__);
-               while (p < e)
-                       printf("%.2x", *p++);
-               printf("\n");
-       }
+       if (debug)
+               dumpkey(k);
 }
 
 int
@@ -224,6 +229,7 @@
                kp = k.data;    
                *ss = kp->ss;
                *c = kp->c;
+               dumpkey(kp);
                memcpy(dbi, v.data, sizeof(*dbi));
                if (debug)
                        printf("%s: returns %d\n", __func__, rv);



Home | Main Index | Thread Index | Old Index