lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 30 Aug 2015 15:24:35 +0200
From:	Matthias Tafelmeier <matthias.tafelmeier@....net>
To:	netdev@...r.kernel.org
Cc:	hagen@...u.net, shemminger@...l.org, fw@...len.de,
	edumazet@...gle.com, daniel@...earbox.net
Subject: [PATCH v4 10/10] ss: extended json_writer for hex field and value output

This small patch extendedis the lib json_writer module for hex field
which is needed in the json format handler of ss.

Signed-off-by: Matthias Tafelmeier <matthias.tafelmeier@....net>
Suggested-by: Hagen Paul Pfeifer <hagen@...u.net>
---
 include/json_writer.h |  3 +++
 lib/json_writer.c     | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/include/json_writer.h b/include/json_writer.h
index ab9a008..6c1581b 100644
--- a/include/json_writer.h
+++ b/include/json_writer.h
@@ -17,6 +17,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <stdio.h>
 
 /* Opaque class structure */
 typedef struct json_writer json_writer_t;
@@ -38,6 +39,7 @@ void jsonw_bool(json_writer_t *self, bool value);
 void jsonw_float(json_writer_t *self, double number);
 void jsonw_uint(json_writer_t *self, uint64_t number);
 void jsonw_int(json_writer_t *self, int64_t number);
+void jsonw_hex(json_writer_t *self, uint64_t num);
 void jsonw_null(json_writer_t *self);
 
 /* Useful Combinations of name and value */
@@ -46,6 +48,7 @@ void jsonw_bool_field(json_writer_t *self, const char *prop, bool value);
 void jsonw_float_field(json_writer_t *self, const char *prop, double num);
 void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t num);
 void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num);
+void jsonw_hex_field(json_writer_t *self, const char *prop, uint64_t num);
 void jsonw_null_field(json_writer_t *self, const char *prop);
 
 /* Collections */
diff --git a/lib/json_writer.c b/lib/json_writer.c
index 2af16e1..495ce57 100644
--- a/lib/json_writer.c
+++ b/lib/json_writer.c
@@ -22,6 +22,8 @@
 
 #include "json_writer.h"
 
+#define notused
+
 struct json_writer {
 	FILE		*out;	/* output file */
 	unsigned	depth;  /* nesting */
@@ -223,6 +225,14 @@ void jsonw_int(json_writer_t *self, int64_t num)
 	jsonw_printf(self, "%"PRId64, num);
 }
 
+void jsonw_hex(json_writer_t *self, uint64_t num)
+{
+	char tmp[17];
+
+	sprintf(tmp, "%"PRIx64, num);
+	jsonw_string(self, tmp);
+}
+
 /* Basic name/value objects */
 void jsonw_string_field(json_writer_t *self, const char *prop, const char *val)
 {
@@ -256,6 +266,12 @@ void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num)
 	jsonw_int(self, num);
 }
 
+void jsonw_hex_field(json_writer_t *self, const char *prop, uint64_t num)
+{
+	jsonw_name(self, prop);
+	jsonw_hex(self, num);
+}
+
 #ifdef notused
 void jsonw_null_field(json_writer_t *self, const char *prop)
 {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ