Send connman mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."
Today's Topics:
1. Re: [PATCH] openvpn: Use proper logging function (Patrik Flykt)
2. [RFC 0/4] Too many DBG() on default (Daniel Wagner)
3. [RFC 1/4] log: Remove unused CONNMAN_DEBUG_FLAG_ALIAS
(Daniel Wagner)
4. [RFC 2/4] main: Make -d option repeatable (Daniel Wagner)
5. [RFC 3/4] log: Count number of -d options invokation
(Daniel Wagner)
6. [RFC 4/4] dnsproxy: Turn normal DBG to verbose DBG to reduce
noise (Daniel Wagner)
----------------------------------------------------------------------
Message: 1
Date: Thu, 06 Oct 2016 11:19:22 +0300
From: Patrik Flykt <[email protected]>
To: Daniel Wagner <[email protected]>, [email protected]
Cc: Daniel Wagner <[email protected]>
Subject: Re: [PATCH] openvpn: Use proper logging function
Message-ID: <[email protected]>
Content-Type: text/plain; charset="UTF-8"
On Wed, 2016-10-05 at 15:44 +0200, Daniel Wagner wrote:
> From: Daniel Wagner <[email protected]>
>
> We should use the connman_{debug|error} functions instead of a plain
> printf for logging.
> ---
Applie, thanks!
Patrik
------------------------------
Message: 2
Date: Thu, 6 Oct 2016 14:48:11 +0200
From: Daniel Wagner <[email protected]>
To: [email protected]
Cc: [email protected], Daniel Wagner <[email protected]>
Subject: [RFC 0/4] Too many DBG() on default
Message-ID: <[email protected]>
From: Daniel Wagner <[email protected]>
Hi,
When turning on the debug option '-d *' the amount of output is just
too much too see what's happening. Especially the dnsproxy code is
very verbose.
There are the ones we should just remove e.g.
connmand[16807]: src/service.c:get_properties() service 0x1c72b40
connmand[16807]: src/ipconfig.c:__connman_ipconfig_append_ipv4config()
connmand[16807]: src/ipconfig.c:__connman_ipconfig_append_ipv6config()
connmand[16807]: src/service.c:get_properties() service 0x1c72b40
connmand[16807]: src/ipconfig.c:__connman_ipconfig_append_ipv4config()
connmand[16807]: src/ipconfig.c:__connman_ipconfig_append_ipv6config()
[...]
And there the ones which do make sense too keep, e.g. the dnsproxy for
low level debugging.
connmand[16807]: src/dnsproxy.c:ns_resolv() cache hit
sync-313-us-west-2.sync.services.mozilla.com. type AAAA
connmand[16807]: src/dnsproxy.c:forward_dns_reply() Received 146 bytes (id
0x015a)
connmand[16807]: src/dnsproxy.c:forward_dns_reply() req 0x1c81210 dstid 0x015a
altid 0x58e0 rcode 0
connmand[16807]: src/dnsproxy.c:cache_update() offset 0 hdr 0x7ffc1cfb0af0 msg
0x7ffc1cfb0af0 rcode 0
connmand[16807]: src/dnsproxy.c:parse_response() qr 1 qdcount 1
connmand[16807]: src/dnsproxy.c:forward_dns_reply() proto 17 sent 146 bytes to
13
connmand[16807]: src/dnsproxy.c:forward_dns_reply() Received 146 bytes (id
0x015a)
connmand[16807]: src/dnsproxy.c:udp_listener_event() Received 37 bytes (id
0x7bb2)
c
I did a quick hack to get a discussion going on the idea to support
debug levels? What do you think on this?
Or should I just do the same with dnsproxy as we have with these here:
README: CONNMAN_DHCP_DEBUG DHCPv4 related debug information
README: CONNMAN_DHCPV6_DEBUG DHCPv6 related debug information
README: CONNMAN_IPTABLES_DEBUG Extra information when iptables is used
README: CONNMAN_RESOLV_DEBUG Name resolver debug prints. These debug
prints
README: CONNMAN_SUPPLICANT_DEBUG Debugging prints for communication between
README: CONNMAN_WEB_DEBUG Debug information when ConnMan does
Internet
Having two ways to enable verbose debugging is confusing IMO. But
then, I don't care too much as long the amount of the default debug
output goes down. It's really hard to find anything useful these days.
cheers,
daniel
Daniel Wagner (3):
log: Remove unused CONNMAN_DEBUG_FLAG_ALIAS
log: Count number of -d options invokation
dnsproxy: Turn normal DBG to verbose DBG to reduce noise
Slava Monich (1):
main: Make -d option repeatable
include/log.h | 18 +++---
src/dnsproxy.c | 192 ++++++++++++++++++++++++++++-----------------------------
src/log.c | 10 +--
src/main.c | 13 +++-
4 files changed, 117 insertions(+), 116 deletions(-)
--
2.7.4
------------------------------
Message: 3
Date: Thu, 6 Oct 2016 14:48:12 +0200
From: Daniel Wagner <[email protected]>
To: [email protected]
Cc: [email protected], Daniel Wagner <[email protected]>
Subject: [RFC 1/4] log: Remove unused CONNMAN_DEBUG_FLAG_ALIAS
Message-ID: <[email protected]>
From: Daniel Wagner <[email protected]>
There is no user of CONNMAN_DEBUG_FLAG_ALIAS, so remove it.
---
include/log.h | 7 -------
src/log.c | 6 ------
2 files changed, 13 deletions(-)
diff --git a/include/log.h b/include/log.h
index 8b00e9dc979c..c2d611f48b0e 100644
--- a/include/log.h
+++ b/include/log.h
@@ -54,16 +54,9 @@ struct connman_debug_desc {
const char *file;
#define CONNMAN_DEBUG_FLAG_DEFAULT (0)
#define CONNMAN_DEBUG_FLAG_PRINT (1 << 0)
-#define CONNMAN_DEBUG_FLAG_ALIAS (1 << 1)
unsigned int flags;
} __attribute__((aligned(8)));
-#define CONNMAN_DEBUG_DEFINE(name) \
- static struct connman_debug_desc __debug_alias_ ## name \
- __attribute__((used, section("__debug"), aligned(8))) = { \
- #name, __FILE__, CONNMAN_DEBUG_FLAG_ALIAS \
- };
-
/**
* DBG:
* @fmt: format string
diff --git a/src/log.c b/src/log.c
index 9bae4a3d63a3..18aae8d9835c 100644
--- a/src/log.c
+++ b/src/log.c
@@ -169,12 +169,6 @@ void __connman_log_enable(struct connman_debug_desc *start,
return;
for (desc = start; desc < stop; desc++) {
- if (desc->flags & CONNMAN_DEBUG_FLAG_ALIAS) {
- file = desc->file;
- name = desc->name;
- continue;
- }
-
if (file || name) {
if (g_strcmp0(desc->file, file) == 0) {
if (!desc->name)
--
2.7.4
------------------------------
Message: 4
Date: Thu, 6 Oct 2016 14:48:13 +0200
From: Daniel Wagner <[email protected]>
To: [email protected]
Subject: [RFC 2/4] main: Make -d option repeatable
Message-ID: <[email protected]>
From: Slava Monich <[email protected]>
Concatenating the patterns makes more sense than using the last
supplied value and leaking the previous allocated patterns.
[wagi: make also -d option without argument repeatable]
---
src/main.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/main.c b/src/main.c
index fdb4f724cf75..db97cd54fb43 100644
--- a/src/main.c
+++ b/src/main.c
@@ -476,10 +476,17 @@ static gboolean option_version = FALSE;
static bool parse_debug(const char *key, const char *value,
gpointer user_data, GError **error)
{
- if (value)
+ if (!value)
+ value = "*";
+
+ if (option_debug) {
+ char *prev = option_debug;
+
+ option_debug = g_strconcat(prev, ",", value, NULL);
+ g_free(prev);
+ } else {
option_debug = g_strdup(value);
- else
- option_debug = g_strdup("*");
+ }
return true;
}
--
2.7.4
------------------------------
Message: 5
Date: Thu, 6 Oct 2016 14:48:14 +0200
From: Daniel Wagner <[email protected]>
To: [email protected]
Cc: [email protected], Daniel Wagner <[email protected]>
Subject: [RFC 3/4] log: Count number of -d options invokation
Message-ID: <[email protected]>
From: Daniel Wagner <[email protected]>
Instead only enabling the debug entry, we also count how many times we
enabled it. That allows different debug levels, e.g. normal debug or
verbose.
E.g. -d -d src/dnsproxy.c enables verbose debugging for dnsproxy.c
---
include/log.h | 11 ++++++++---
src/log.c | 4 +++-
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/include/log.h b/include/log.h
index c2d611f48b0e..916c3aa4a17c 100644
--- a/include/log.h
+++ b/include/log.h
@@ -54,7 +54,8 @@ struct connman_debug_desc {
const char *file;
#define CONNMAN_DEBUG_FLAG_DEFAULT (0)
#define CONNMAN_DEBUG_FLAG_PRINT (1 << 0)
- unsigned int flags;
+ unsigned short flags;
+ unsigned short count;
} __attribute__((aligned(8)));
/**
@@ -65,16 +66,20 @@ struct connman_debug_desc {
* Simple macro around connman_debug() which also include the function
* name it is called in.
*/
-#define DBG(fmt, arg...) do { \
+#define DBGL(cnt, fmt, arg...) do { \
static struct connman_debug_desc __connman_debug_desc \
__attribute__((used, section("__debug"), aligned(8))) = { \
.file = __FILE__, .flags = CONNMAN_DEBUG_FLAG_DEFAULT, \
+ .count = cnt, \
}; \
- if (__connman_debug_desc.flags & CONNMAN_DEBUG_FLAG_PRINT) \
+ if (__connman_debug_desc.flags & CONNMAN_DEBUG_FLAG_PRINT && \
+ __connman_debug_desc.count >= cnt) \
connman_debug("%s:%s() " fmt, \
__FILE__, __FUNCTION__ , ## arg); \
} while (0)
+#define DBG(fmt, arg...) DBGL(1, fmt, ## arg)
+
#ifdef __cplusplus
}
#endif
diff --git a/src/log.c b/src/log.c
index 18aae8d9835c..f239f4b7f1f5 100644
--- a/src/log.c
+++ b/src/log.c
@@ -177,8 +177,10 @@ void __connman_log_enable(struct connman_debug_desc *start,
file = NULL;
}
- if (is_enabled(desc))
+ if (is_enabled(desc)) {
desc->flags |= CONNMAN_DEBUG_FLAG_PRINT;
+ desc->count++;
+ }
}
}
--
2.7.4
------------------------------
Message: 6
Date: Thu, 6 Oct 2016 14:48:15 +0200
From: Daniel Wagner <[email protected]>
To: [email protected]
Cc: [email protected], Daniel Wagner <[email protected]>
Subject: [RFC 4/4] dnsproxy: Turn normal DBG to verbose DBG to reduce
noise
Message-ID: <[email protected]>
From: Daniel Wagner <[email protected]>
The debug printing of dnsproxy is very noise. Only print them when we
really are interested in verbose debugging.
---
src/dnsproxy.c | 192 ++++++++++++++++++++++++++++-----------------------------
1 file changed, 96 insertions(+), 96 deletions(-)
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index f3ebcf0e87ab..64eb2d4779bf 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -282,7 +282,7 @@ static struct server_data *find_server(int index,
{
GSList *list;
- DBG("index %d server %s proto %d", index, server, protocol);
+ DBGL(2, "index %d server %s proto %d", index, server, protocol);
for (list = server_list; list; list = list->next) {
struct server_data *data = list->data;
@@ -333,14 +333,14 @@ static void refresh_dns_entry(struct cache_entry *entry,
char *name)
}
if (!entry->ipv4) {
- DBG("Refreshing A record for %s", name);
+ DBGL(2, "Refreshing A record for %s", name);
g_resolv_lookup_hostname(ipv4_resolve, name,
dummy_resolve_func, NULL);
age = 4;
}
if (!entry->ipv6) {
- DBG("Refreshing AAAA record for %s", name);
+ DBGL(2, "Refreshing AAAA record for %s", name);
g_resolv_lookup_hostname(ipv6_resolve, name,
dummy_resolve_func, NULL);
age = 4;
@@ -452,7 +452,7 @@ static void send_cached_response(int sk, unsigned char
*buf, int len,
else
update_cached_ttl((unsigned char *)hdr, adj_len, ttl);
- DBG("sk %d id 0x%04x answers %d ptr %p length %d dns %d",
+ DBGL(2, "sk %d id 0x%04x answers %d ptr %p length %d dns %d",
sk, hdr->id, answers, ptr, len, dns_len);
err = sendto(sk, ptr, len, MSG_NOSIGNAL, to, tolen);
@@ -464,7 +464,7 @@ static void send_cached_response(int sk, unsigned char
*buf, int len,
if (err != len || (dns_len != (len - 2) && protocol == IPPROTO_TCP) ||
(dns_len != len && protocol == IPPROTO_UDP))
- DBG("Packet length mismatch, sent %d wanted %d dns %d",
+ DBGL(2, "Packet length mismatch, sent %d wanted %d dns %d",
err, len, dns_len);
}
@@ -475,7 +475,7 @@ static void send_response(int sk, unsigned char *buf, int
len,
struct domain_hdr *hdr;
int err, offset = protocol_offset(protocol);
- DBG("sk %d", sk);
+ DBGL(2, "sk %d", sk);
if (offset < 0)
return;
@@ -485,7 +485,7 @@ static void send_response(int sk, unsigned char *buf, int
len,
hdr = (void *) (buf + offset);
- DBG("id 0x%04x qr %d opcode %d", hdr->id, hdr->qr, hdr->opcode);
+ DBGL(2, "id 0x%04x qr %d opcode %d", hdr->id, hdr->qr, hdr->opcode);
hdr->qr = 1;
hdr->rcode = ns_r_servfail;
@@ -537,7 +537,7 @@ static gboolean request_timeout(gpointer user_data)
if (!req)
return FALSE;
- DBG("id 0x%04x", req->srcid);
+ DBGL(2, "id 0x%04x", req->srcid);
request_list = g_slist_remove(request_list, req);
@@ -579,7 +579,7 @@ static gboolean request_timeout(gpointer user_data)
* if we get a request timeout from server.
*/
if (req->protocol == IPPROTO_TCP) {
- DBG("client %d removed", req->client_sk);
+ DBGL(2, "client %d removed", req->client_sk);
g_hash_table_remove(partial_tcp_req_table,
GINT_TO_POINTER(req->client_sk));
}
@@ -597,7 +597,7 @@ static int append_query(unsigned char *buf, unsigned int
size,
unsigned char *ptr = buf;
int len;
- DBG("query %s domain %s", query, domain);
+ DBGL(2, "query %s domain %s", query, domain);
while (query) {
const char *tmp;
@@ -667,7 +667,7 @@ static void cache_enforce_validity(struct cache_entry
*entry)
if (!cache_check_is_valid(entry->ipv4, current_time)
&& entry->ipv4) {
- DBG("cache timeout \"%s\" type A", entry->key);
+ DBGL(2, "cache timeout \"%s\" type A", entry->key);
g_free(entry->ipv4->data);
g_free(entry->ipv4);
entry->ipv4 = NULL;
@@ -676,7 +676,7 @@ static void cache_enforce_validity(struct cache_entry
*entry)
if (!cache_check_is_valid(entry->ipv6, current_time)
&& entry->ipv6) {
- DBG("cache timeout \"%s\" type AAAA", entry->key);
+ DBGL(2, "cache timeout \"%s\" type AAAA", entry->key);
g_free(entry->ipv6->data);
g_free(entry->ipv6);
entry->ipv6 = NULL;
@@ -701,7 +701,7 @@ static uint16_t cache_check_validity(char *question,
uint16_t type,
switch (type) {
case 1: /* IPv4 */
if (!cache_check_is_valid(entry->ipv4, current_time)) {
- DBG("cache %s \"%s\" type A", entry->ipv4 ?
+ DBGL(2, "cache %s \"%s\" type A", entry->ipv4 ?
"timeout" : "entry missing", question);
if (want_refresh)
@@ -720,7 +720,7 @@ static uint16_t cache_check_validity(char *question,
uint16_t type,
case 28: /* IPv6 */
if (!cache_check_is_valid(entry->ipv6, current_time)) {
- DBG("cache %s \"%s\" type AAAA", entry->ipv6 ?
+ DBGL(2, "cache %s \"%s\" type AAAA", entry->ipv6 ?
"timeout" : "entry missing", question);
if (want_refresh)
@@ -766,7 +766,7 @@ static gboolean try_remove_cache(gpointer user_data)
cache_timer = 0;
if (__sync_fetch_and_sub(&cache_refcount, 1) == 1) {
- DBG("No cache users, removing it.");
+ DBGL(2, "No cache users, removing it.");
g_hash_table_destroy(cache);
cache = NULL;
@@ -980,7 +980,7 @@ static int parse_response(unsigned char *buf, int buflen,
if (buflen < 12)
return -EINVAL;
- DBG("qr %d qdcount %d", hdr->qr, qdcount);
+ DBGL(2, "qr %d qdcount %d", hdr->qr, qdcount);
/* We currently only cache responses where question count is 1 */
if (hdr->qr != 1 || qdcount != 1)
@@ -1225,7 +1225,7 @@ static void cache_cleanup(void)
count = g_hash_table_foreach_remove(cache, cache_check_entry,
&data);
}
- DBG("removed %d in the first pass", count);
+ DBGL(2, "removed %d in the first pass", count);
/*
* In the second pass, if the first pass turned up blank,
@@ -1289,7 +1289,7 @@ static gboolean cache_invalidate_entry(gpointer key,
gpointer value,
*/
static void cache_invalidate(void)
{
- DBG("Invalidating the DNS cache %p", cache);
+ DBGL(2, "Invalidating the DNS cache %p", cache);
if (!cache)
return;
@@ -1321,7 +1321,7 @@ static void cache_refresh_entry(struct cache_entry *entry)
*c = '.';
c += jump + 1;
}
- DBG("Refreshing %s\n", dns_name);
+ DBGL(2, "Refreshing %s\n", dns_name);
/* then refresh the hostname */
refresh_dns_entry(entry, &dns_name[1]);
}
@@ -1398,7 +1398,7 @@ static int cache_update(struct server_data *srv, unsigned
char *msg,
if (offset < 0)
return 0;
- DBG("offset %d hdr %p msg %p rcode %d", offset, hdr, msg, hdr->rcode);
+ DBGL(2, "offset %d hdr %p msg %p rcode %d", offset, hdr, msg,
hdr->rcode);
/* Continue only if response code is 0 (=ok) */
if (hdr->rcode != ns_r_noerror)
@@ -1578,7 +1578,7 @@ static int cache_update(struct server_data *srv, unsigned
char *msg,
cache_size++;
}
- DBG("cache %d %squestion \"%s\" type %d ttl %d size %zd packet %u "
+ DBGL(2, "cache %d %squestion \"%s\" type %d ttl %d size %zd packet %u "
"dns len %u",
cache_size, new_entry ? "new " : "old ",
question, type, ttl,
@@ -1604,7 +1604,7 @@ static int ns_resolv(struct server_data *server, struct
request_data *req,
int ttl_left = 0;
struct cache_data *data;
- DBG("cache hit %s type %s", lookup, type == 1 ? "A" : "AAAA");
+ DBGL(2, "cache hit %s type %s", lookup, type == 1 ? "A" :
"AAAA");
if (type == 1)
data = entry->ipv4;
else
@@ -1641,7 +1641,7 @@ static int ns_resolv(struct server_data *server, struct
request_data *req,
err = sendto(sk, request, req->request_len, MSG_NOSIGNAL,
server->server_addr, server->server_addr_len);
if (err < 0) {
- DBG("Cannot send message to server %s sock %d "
+ DBGL(2, "Cannot send message to server %s sock %d "
"protocol %d (%s/%d)",
server->server, sk, server->protocol,
strerror(errno), errno);
@@ -1701,7 +1701,7 @@ static int ns_resolv(struct server_data *server, struct
request_data *req,
alt[1] = req_len & 0xff;
}
- DBG("req %p dstid 0x%04x altid 0x%04x", req, req->dstid,
+ DBGL(2, "req %p dstid 0x%04x altid 0x%04x", req, req->dstid,
req->altid);
err = send(sk, alt, req->request_len + domlen, MSG_NOSIGNAL);
@@ -1723,7 +1723,7 @@ static char *convert_label(char *start, char *end, char
*ptr, char *uptr,
pos = dn_expand((u_char *)start, (u_char *)end, (u_char *)ptr,
name, NS_MAXLABEL);
if (pos < 0) {
- DBG("uncompress error [%d/%s]", errno, strerror(errno));
+ DBGL(2, "uncompress error [%d/%s]", errno, strerror(errno));
goto out;
}
@@ -1733,7 +1733,7 @@ static char *convert_label(char *start, char *end, char
*ptr, char *uptr,
*/
comp_pos = dn_comp(name, (u_char *)uptr, remaining_len, NULL, NULL);
if (comp_pos < 0) {
- DBG("compress error [%d/%s]", errno, strerror(errno));
+ DBGL(2, "compress error [%d/%s]", errno, strerror(errno));
goto out;
}
@@ -1752,7 +1752,7 @@ static char *uncompress(int16_t field_count, char *start,
char *end,
{
char *uptr = *uncompressed_ptr; /* position in result buffer */
- DBG("count %d ptr %p end %p uptr %p", field_count, ptr, end, uptr);
+ DBGL(2, "count %d ptr %p end %p uptr %p", field_count, ptr, end, uptr);
while (field_count-- > 0 && ptr < end) {
int dlen; /* data field length */
@@ -1774,7 +1774,7 @@ static char *uncompress(int16_t field_count, char *start,
char *end,
ulen = strlen(name);
strncpy(uptr, name, uncomp_len - (uptr - uncompressed));
- DBG("pos %d ulen %d left %d name %s", pos, ulen,
+ DBGL(2, "pos %d ulen %d left %d name %s", pos, ulen,
(int)(uncomp_len - (uptr - uncompressed)), uptr);
uptr += ulen;
@@ -1818,7 +1818,7 @@ static char *uncompress(int16_t field_count, char *start,
char *end,
dlen = uptr[-2] << 8 | uptr[-1];
if (ptr + dlen > end) {
- DBG("data len %d too long", dlen);
+ DBGL(2, "data len %d too long", dlen);
goto out;
}
@@ -1929,13 +1929,13 @@ static int forward_dns_reply(unsigned char *reply, int
reply_len, int protocol,
hdr = (void *)(reply + offset);
dns_id = reply[offset] | reply[offset + 1] << 8;
- DBG("Received %d bytes (id 0x%04x)", reply_len, dns_id);
+ DBGL(2, "Received %d bytes (id 0x%04x)", reply_len, dns_id);
req = find_request(dns_id);
if (!req)
return -EINVAL;
- DBG("req %p dstid 0x%04x altid 0x%04x rcode %d",
+ DBGL(2, "req %p dstid 0x%04x altid 0x%04x rcode %d",
req, req->dstid, req->altid, hdr->rcode);
reply[offset] = req->srcid & 0xff;
@@ -1991,7 +1991,7 @@ static int forward_dns_reply(unsigned char *reply, int
reply_len, int protocol,
ptr[dns_type_pos + 3];
if (dns_type != ns_t_a && dns_type != ns_t_aaaa &&
dns_class != ns_c_in) {
- DBG("Pass msg dns type %d class %d",
+ DBGL(2, "Pass msg dns type %d class %d",
dns_type, dns_class);
goto pass;
}
@@ -2080,7 +2080,7 @@ static int forward_dns_reply(unsigned char *reply, int
reply_len, int protocol,
new_len = strip_domains(uncompressed, answers,
uptr - answers);
if (new_len < 0) {
- DBG("Corrupted packet");
+ DBGL(2, "Corrupted packet");
return -EINVAL;
}
@@ -2145,10 +2145,10 @@ static int forward_dns_reply(unsigned char *reply, int
reply_len, int protocol,
}
if (err < 0)
- DBG("Cannot send msg, sk %d proto %d errno %d/%s", sk,
+ DBGL(2, "Cannot send msg, sk %d proto %d errno %d/%s", sk,
protocol, errno, strerror(errno));
else
- DBG("proto %d sent %d bytes to %d", protocol, err, sk);
+ DBGL(2, "proto %d sent %d bytes to %d", protocol, err, sk);
destroy_request_data(req);
@@ -2157,7 +2157,7 @@ static int forward_dns_reply(unsigned char *reply, int
reply_len, int protocol,
static void server_destroy_socket(struct server_data *data)
{
- DBG("index %d server %s proto %d", data->index,
+ DBGL(2, "index %d server %s proto %d", data->index,
data->server, data->protocol);
if (data->watch > 0) {
@@ -2182,7 +2182,7 @@ static void server_destroy_socket(struct server_data
*data)
static void destroy_server(struct server_data *server)
{
- DBG("index %d server %s sock %d", server->index, server->server,
+ DBGL(2, "index %d server %s sock %d", server->index, server->server,
server->channel ?
g_io_channel_unix_get_fd(server->channel): -1);
@@ -2190,7 +2190,7 @@ static void destroy_server(struct server_data *server)
server_destroy_socket(server);
if (server->protocol == IPPROTO_UDP && server->enabled)
- DBG("Removing DNS server %s", server->server);
+ DBGL(2, "Removing DNS server %s", server->server);
g_free(server->server);
g_list_free_full(server->domains, g_free);
@@ -2250,7 +2250,7 @@ static gboolean tcp_server_event(GIOChannel *channel,
GIOCondition condition,
if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
GSList *list;
hangup:
- DBG("TCP server channel closed, sk %d", sk);
+ DBGL(2, "TCP server channel closed, sk %d", sk);
/*
* Discard any partial response which is buffered; better
@@ -2305,7 +2305,7 @@ static gboolean tcp_server_event(GIOChannel *channel,
GIOCondition condition,
domains = domains->next) {
char *dom = domains->data;
- DBG("Adding domain %s to %s",
+ DBGL(2, "Adding domain %s to %s",
dom, server->server);
server->domains = g_list_append(server->domains,
@@ -2330,7 +2330,7 @@ static gboolean tcp_server_event(GIOChannel *channel,
GIOCondition condition,
continue;
}
- DBG("Sending req %s over TCP", (char *)req->name);
+ DBGL(2, "Sending req %s over TCP", (char *)req->name);
status = ns_resolv(server, req,
req->request, req->name);
@@ -2389,7 +2389,7 @@ static gboolean tcp_server_event(GIOChannel *channel,
GIOCondition condition,
reply_len = reply_len_buf[1] | reply_len_buf[0] << 8;
reply_len += 2;
- DBG("TCP reply %d bytes from %d", reply_len, sk);
+ DBGL(2, "TCP reply %d bytes from %d", reply_len, sk);
reply = g_try_malloc(sizeof(*reply) + reply_len + 2);
if (!reply)
@@ -2436,7 +2436,7 @@ static gboolean tcp_idle_timeout(gpointer user_data)
{
struct server_data *server = user_data;
- DBG("");
+ DBGL(2, "");
if (!server)
return FALSE;
@@ -2451,7 +2451,7 @@ static int server_create_socket(struct server_data *data)
int sk, err;
char *interface;
- DBG("index %d server %s proto %d", data->index,
+ DBGL(2, "index %d server %s proto %d", data->index,
data->server, data->protocol);
sk = socket(data->server_addr->sa_family,
@@ -2465,7 +2465,7 @@ static int server_create_socket(struct server_data *data)
return -err;
}
- DBG("sk %d", sk);
+ DBGL(2, "sk %d", sk);
interface = connman_inet_ifname(data->index);
if (interface) {
@@ -2536,9 +2536,9 @@ static void enable_fallback(bool enable)
continue;
if (enable)
- DBG("Enabling fallback DNS server %s", data->server);
+ DBGL(2, "Enabling fallback DNS server %s",
data->server);
else
- DBG("Disabling fallback DNS server %s", data->server);
+ DBGL(2, "Disabling fallback DNS server %s",
data->server);
data->enabled = enable;
}
@@ -2552,7 +2552,7 @@ static struct server_data *create_server(int index,
struct addrinfo hints, *rp;
int ret;
- DBG("index %d server %s", index, server);
+ DBGL(2, "index %d server %s", index, server);
data = g_try_new0(struct server_data, 1);
if (!data) {
@@ -2629,7 +2629,7 @@ static struct server_data *create_server(int index,
__connman_service_index_is_split_routing(
data->index)) {
data->enabled = true;
- DBG("Adding DNS server %s", data->server);
+ DBGL(2, "Adding DNS server %s", data->server);
enable_fallback(false);
}
@@ -2649,18 +2649,18 @@ static bool resolv(struct request_data *req,
struct server_data *data = list->data;
if (data->protocol == IPPROTO_TCP) {
- DBG("server %s ignored proto TCP", data->server);
+ DBGL(2, "server %s ignored proto TCP", data->server);
continue;
}
- DBG("server %s enabled %d", data->server, data->enabled);
+ DBGL(2, "server %s enabled %d", data->server, data->enabled);
if (!data->enabled)
continue;
if (!data->channel && data->protocol == IPPROTO_UDP) {
if (server_create_socket(data) < 0) {
- DBG("socket creation failed while resolving");
+ DBGL(2, "socket creation failed while
resolving");
continue;
}
}
@@ -2676,7 +2676,7 @@ static void update_domain(int index, const char *domain,
bool append)
{
GSList *list;
- DBG("index %d domain %s", index, domain);
+ DBGL(2, "index %d domain %s", index, domain);
if (!domain)
return;
@@ -2757,7 +2757,7 @@ int __connman_dnsproxy_append(int index, const char
*domain,
{
struct server_data *data;
- DBG("index %d server %s", index, server);
+ DBGL(2, "index %d server %s", index, server);
if (!server && !domain)
return -EINVAL;
@@ -2814,7 +2814,7 @@ static void remove_server(int index, const char *domain,
int __connman_dnsproxy_remove(int index, const char *domain,
const char *server)
{
- DBG("index %d server %s", index, server);
+ DBGL(2, "index %d server %s", index, server);
if (!server && !domain)
return -EINVAL;
@@ -2841,18 +2841,18 @@ static void dnsproxy_offline_mode(bool enabled)
{
GSList *list;
- DBG("enabled %d", enabled);
+ DBGL(2, "enabled %d", enabled);
for (list = server_list; list; list = list->next) {
struct server_data *data = list->data;
if (!enabled) {
- DBG("Enabling DNS server %s", data->server);
+ DBGL(2, "Enabling DNS server %s", data->server);
data->enabled = true;
cache_invalidate();
cache_refresh();
} else {
- DBG("Disabling DNS server %s", data->server);
+ DBGL(2, "Disabling DNS server %s", data->server);
data->enabled = false;
cache_invalidate();
}
@@ -2865,7 +2865,7 @@ static void dnsproxy_default_changed(struct
connman_service *service)
GSList *list;
int index;
- DBG("service %p", service);
+ DBGL(2, "service %p", service);
/* DNS has changed, invalidate the cache */
cache_invalidate();
@@ -2884,11 +2884,11 @@ static void dnsproxy_default_changed(struct
connman_service *service)
struct server_data *data = list->data;
if (data->index == index) {
- DBG("Enabling DNS server %s", data->server);
+ DBGL(2, "Enabling DNS server %s", data->server);
data->enabled = true;
server_enabled = true;
} else {
- DBG("Disabling DNS server %s", data->server);
+ DBGL(2, "Disabling DNS server %s", data->server);
data->enabled = false;
}
}
@@ -2920,7 +2920,7 @@ static int parse_request(unsigned char *buf, int len,
if (len < 12)
return -EINVAL;
- DBG("id 0x%04x qr %d opcode %d qdcount %d arcount %d",
+ DBGL(2, "id 0x%04x qr %d opcode %d qdcount %d arcount %d",
hdr->id, hdr->qr, hdr->opcode,
qdcount, arcount);
@@ -2958,7 +2958,7 @@ static int parse_request(unsigned char *buf, int len,
edns0_bufsize = last_label[7] << 8 | last_label[8];
- DBG("EDNS0 buffer size %u", edns0_bufsize);
+ DBGL(2, "EDNS0 buffer size %u", edns0_bufsize);
/* This is an evil hack until full TCP support has been
* implemented.
@@ -2974,7 +2974,7 @@ static int parse_request(unsigned char *buf, int len,
}
}
- DBG("query %s", name);
+ DBGL(2, "query %s", name);
return 0;
}
@@ -2985,7 +2985,7 @@ static void client_reset(struct tcp_partial_client_data
*client)
return;
if (client->channel) {
- DBG("client %d closing",
+ DBGL(2, "client %d closing",
g_io_channel_unix_get_fd(client->channel));
g_io_channel_unref(client->channel);
@@ -3029,14 +3029,14 @@ static bool read_tcp_data(struct
tcp_partial_client_data *client,
client_sk = g_io_channel_unix_get_fd(client->channel);
if (read_len == 0) {
- DBG("client %d closed, pending %d bytes",
+ DBGL(2, "client %d closed, pending %d bytes",
client_sk, client->buf_end);
g_hash_table_remove(partial_tcp_req_table,
GINT_TO_POINTER(client_sk));
return false;
}
- DBG("client %d received %d bytes", client_sk, read_len);
+ DBGL(2, "client %d received %d bytes", client_sk, read_len);
client->buf_end += read_len;
@@ -3045,24 +3045,24 @@ static bool read_tcp_data(struct
tcp_partial_client_data *client,
msg_len = get_msg_len(client->buf);
if (msg_len > TCP_MAX_BUF_LEN) {
- DBG("client %d sent too much data %d", client_sk, msg_len);
+ DBGL(2, "client %d sent too much data %d", client_sk, msg_len);
g_hash_table_remove(partial_tcp_req_table,
GINT_TO_POINTER(client_sk));
return false;
}
read_another:
- DBG("client %d msg len %d end %d past end %d", client_sk, msg_len,
+ DBGL(2, "client %d msg len %d end %d past end %d", client_sk, msg_len,
client->buf_end, client->buf_end - (msg_len + 2));
if (client->buf_end < (msg_len + 2)) {
- DBG("client %d still missing %d bytes",
+ DBGL(2, "client %d still missing %d bytes",
client_sk,
msg_len + 2 - client->buf_end);
return true;
}
- DBG("client %d all data %d received", client_sk, msg_len);
+ DBGL(2, "client %d all data %d received", client_sk, msg_len);
err = parse_request(client->buf + 2, msg_len,
query, sizeof(query));
@@ -3103,7 +3103,7 @@ static bool read_tcp_data(struct tcp_partial_client_data
*client,
int ttl_left = 0;
struct cache_data *data;
- DBG("cache hit %s type %s", query, qtype == 1 ? "A" : "AAAA");
+ DBGL(2, "cache hit %s type %s", query, qtype == 1 ? "A" :
"AAAA");
if (qtype == 1)
data = entry->ipv4;
else
@@ -3120,7 +3120,7 @@ static bool read_tcp_data(struct tcp_partial_client_data
*client,
g_free(req);
goto out;
} else
- DBG("data missing, ignoring cache for this query");
+ DBGL(2, "data missing, ignoring cache for this query");
}
for (list = server_list; list; list = list->next) {
@@ -3175,7 +3175,7 @@ static bool read_tcp_data(struct tcp_partial_client_data
*client,
out:
if (client->buf_end > (msg_len + 2)) {
- DBG("client %d buf %p -> %p end %d len %d new %d",
+ DBGL(2, "client %d buf %p -> %p end %d len %d new %d",
client_sk,
client->buf + msg_len + 2,
client->buf, client->buf_end,
@@ -3191,12 +3191,12 @@ static bool read_tcp_data(struct
tcp_partial_client_data *client,
*/
msg_len = get_msg_len(client->buf);
if ((msg_len + 2) == client->buf_end) {
- DBG("client %d reading another %d bytes", client_sk,
+ DBGL(2, "client %d reading another %d bytes", client_sk,
msg_len + 2);
goto read_another;
}
} else {
- DBG("client %d clearing reading buffer", client_sk);
+ DBGL(2, "client %d clearing reading buffer", client_sk);
client->buf_end = 0;
memset(client->buf, 0, TCP_MAX_BUF_LEN);
@@ -3258,7 +3258,7 @@ static gboolean tcp_client_event(GIOChannel *channel,
GIOCondition condition,
if (errno == EAGAIN || errno == EWOULDBLOCK)
return TRUE;
- DBG("client %d cannot read errno %d/%s", client_sk, -errno,
+ DBGL(2, "client %d cannot read errno %d/%s", client_sk, -errno,
strerror(errno));
g_hash_table_remove(partial_tcp_req_table,
GINT_TO_POINTER(client_sk));
@@ -3275,7 +3275,7 @@ static gboolean client_timeout(gpointer user_data)
sock = g_io_channel_unix_get_fd(client->channel);
- DBG("client %d timeout pending %d bytes", sock, client->buf_end);
+ DBGL(2, "client %d timeout pending %d bytes", sock, client->buf_end);
g_hash_table_remove(partial_tcp_req_table, GINT_TO_POINTER(sock));
@@ -3298,7 +3298,7 @@ static bool tcp_listener_event(GIOChannel *channel,
GIOCondition condition,
struct timeval tv;
fd_set readfds;
- DBG("condition 0x%02x channel %p ifdata %p family %d",
+ DBGL(2, "condition 0x%02x channel %p ifdata %p family %d",
condition, channel, ifdata, family);
if (condition & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
@@ -3328,9 +3328,9 @@ static bool tcp_listener_event(GIOChannel *channel,
GIOCondition condition,
select(sk + 1, &readfds, NULL, NULL, &tv);
if (FD_ISSET(sk, &readfds)) {
client_sk = accept(sk, client_addr, client_addr_len);
- DBG("client %d accepted", client_sk);
+ DBGL(2, "client %d accepted", client_sk);
} else {
- DBG("No data to read from master %d, waiting.", sk);
+ DBGL(2, "No data to read from master %d, waiting.", sk);
return true;
}
@@ -3364,9 +3364,9 @@ static bool tcp_listener_event(GIOChannel *channel,
GIOCondition condition,
client->ifdata = ifdata;
- DBG("client %d created %p", client_sk, client);
+ DBGL(2, "client %d created %p", client_sk, client);
} else {
- DBG("client %d already exists %p", client_sk, client);
+ DBGL(2, "client %d already exists %p", client_sk, client);
}
if (!client->buf) {
@@ -3390,11 +3390,11 @@ static bool tcp_listener_event(GIOChannel *channel,
GIOCondition condition,
len = recv(client_sk, client->buf, TCP_MAX_BUF_LEN, 0);
if (len < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
- DBG("client %d no data to read, waiting", client_sk);
+ DBGL(2, "client %d no data to read, waiting",
client_sk);
return true;
}
- DBG("client %d cannot read errno %d/%s", client_sk, -errno,
+ DBGL(2, "client %d cannot read errno %d/%s", client_sk, -errno,
strerror(errno));
g_hash_table_remove(partial_tcp_req_table,
GINT_TO_POINTER(client_sk));
@@ -3402,14 +3402,14 @@ static bool tcp_listener_event(GIOChannel *channel,
GIOCondition condition,
}
if (len < 2) {
- DBG("client %d not enough data to read, waiting", client_sk);
+ DBGL(2, "client %d not enough data to read, waiting",
client_sk);
client->buf_end += len;
return true;
}
msg_len = get_msg_len(client->buf);
if (msg_len > TCP_MAX_BUF_LEN) {
- DBG("client %d invalid message length %u ignoring packet",
+ DBGL(2, "client %d invalid message length %u ignoring packet",
client_sk, msg_len);
g_hash_table_remove(partial_tcp_req_table,
GINT_TO_POINTER(client_sk));
@@ -3421,7 +3421,7 @@ static bool tcp_listener_event(GIOChannel *channel,
GIOCondition condition,
* that is the reason to -2 below.
*/
if (msg_len != (unsigned int)(len - 2)) {
- DBG("client %d sent %d bytes but expecting %u pending %d",
+ DBGL(2, "client %d sent %d bytes but expecting %u pending %d",
client_sk, len, msg_len + 2, msg_len + 2 - len);
client->buf_end += len;
@@ -3485,7 +3485,7 @@ static bool udp_listener_event(GIOChannel *channel,
GIOCondition condition,
if (len < 2)
return true;
- DBG("Received %d bytes (id 0x%04x)", len, buf[0] | buf[1] << 8);
+ DBGL(2, "Received %d bytes (id 0x%04x)", len, buf[0] | buf[1] << 8);
err = parse_request(buf, len, query, sizeof(query));
if (err < 0 || (g_slist_length(server_list) == 0)) {
@@ -3562,7 +3562,7 @@ static GIOChannel *get_listener(int family, int protocol,
int index)
int sk, type;
char *interface;
- DBG("family %d protocol %d index %d", family, protocol, index);
+ DBGL(2, "family %d protocol %d index %d", family, protocol, index);
switch (protocol) {
case IPPROTO_UDP:
@@ -3728,7 +3728,7 @@ static int create_dns_listener(int protocol, struct
listener_data *ifdata)
static void destroy_udp_listener(struct listener_data *ifdata)
{
- DBG("index %d", ifdata->index);
+ DBGL(2, "index %d", ifdata->index);
if (ifdata->udp4_listener_watch > 0)
g_source_remove(ifdata->udp4_listener_watch);
@@ -3744,7 +3744,7 @@ static void destroy_udp_listener(struct listener_data
*ifdata)
static void destroy_tcp_listener(struct listener_data *ifdata)
{
- DBG("index %d", ifdata->index);
+ DBGL(2, "index %d", ifdata->index);
if (ifdata->tcp4_listener_watch > 0)
g_source_remove(ifdata->tcp4_listener_watch);
@@ -3797,7 +3797,7 @@ static void destroy_listener(struct listener_data *ifdata)
for (list = request_list; list; list = list->next) {
struct request_data *req = list->data;
- DBG("Dropping request (id 0x%04x -> 0x%04x)",
+ DBGL(2, "Dropping request (id 0x%04x -> 0x%04x)",
req->srcid, req->dstid);
destroy_request_data(req);
list->data = NULL;
@@ -3815,7 +3815,7 @@ int __connman_dnsproxy_add_listener(int index)
struct listener_data *ifdata;
int err;
- DBG("index %d", index);
+ DBGL(2, "index %d", index);
if (index < 0)
return -EINVAL;
@@ -3856,7 +3856,7 @@ void __connman_dnsproxy_remove_listener(int index)
{
struct listener_data *ifdata;
- DBG("index %d", index);
+ DBGL(2, "index %d", index);
if (!listener_table)
return;
@@ -3875,7 +3875,7 @@ static void remove_listener(gpointer key, gpointer value,
gpointer user_data)
int index = GPOINTER_TO_INT(key);
struct listener_data *ifdata = value;
- DBG("index %d", index);
+ DBGL(2, "index %d", index);
destroy_listener(ifdata);
}
--
2.7.4
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 12, Issue 5
**************************************