annotate extensions/dbg_msg_dumps/dbg_msg_dumps.c @ 1306:0d15dad33f0b

Fix logic error when calling fd_msg_source_get().
author Thomas Klausner <tk@giga.or.at>
date Mon, 29 Jun 2015 09:37:35 +0200
parents 2c09e2545188
children 7a2ab0087788
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1126
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
1 /*********************************************************************************************************
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
2 * Software License Agreement (BSD License) *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
4 * *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
5 * Copyright (c) 2013, WIDE Project and NICT *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
6 * All rights reserved. *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
7 * *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
9 * permitted provided that the following conditions are met: *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
10 * *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
11 * * Redistributions of source code must retain the above *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
12 * copyright notice, this list of conditions and the *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
13 * following disclaimer. *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
14 * *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
15 * * Redistributions in binary form must reproduce the above *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
16 * copyright notice, this list of conditions and the *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
17 * following disclaimer in the documentation and/or other *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
18 * materials provided with the distribution. *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
19 * *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
20 * * Neither the name of the WIDE Project or NICT nor the *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
21 * names of its contributors may be used to endorse or *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
22 * promote products derived from this software without *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
23 * specific prior written permission of WIDE Project and *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
24 * NICT. *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
25 * *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
34 *********************************************************************************************************/
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
35
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
36 /* This extension uses the hooks mechanism to display the full content of received and sent messages, for
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
37 learning & debugging purpose.
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
38 Do NOT use this extension in production environment because it will slow down all operation. */
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
39
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
40 /* You can add a configuration parameter on the LoadExtension line, e.g.
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
41 LoadExtension="dbg_msg_dump.fdx":"0x149";
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
42 The value is an hexadecimal value with the following bits meaning: */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
43 #define HK_ERRORS_QUIET 0x0001 /* errors are not dumped -- removes the default handling as well */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
44 #define HK_ERRORS_COMPACT 0x0002 /* errors in compact mode */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
45 #define HK_ERRORS_FULL 0x0004 /* errors in full mode (1 line with all the data) */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
46 #define HK_ERRORS_TREE 0x0008 /* errors in treeview mode (message split over multiple lines) */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
47
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
48 #define HK_SNDRCV_QUIET 0x0010 /* send+rcv are not dumped -- removes the default handling as well */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
49 #define HK_SNDRCV_COMPACT 0x0020 /* send+rcv in compact mode */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
50 #define HK_SNDRCV_FULL 0x0040 /* send+rcv in full mode */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
51 #define HK_SNDRCV_TREE 0x0080 /* send+rcv in tree mode */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
52
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
53 #define HK_ROUTING_QUIET 0x0100 /* routing decisions are not dumped -- removes the default handling as well */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
54 #define HK_ROUTING_COMPACT 0x0200 /* routing decisions in compact mode */
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
55 #define HK_ROUTING_FULL 0x0400 /* routing decisions in full mode */
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
56 #define HK_ROUTING_TREE 0x0800 /* routing decisions in tree mode */
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
57
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
58 #define HK_PEERS_QUIET 0x1000 /* peers connections events are not dumped -- removes the default handling as well */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
59 #define HK_PEERS_COMPACT 0x2000 /* peers connections events in compact mode */
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
60 #define HK_PEERS_FULL 0x4000 /* peers connections events in full mode */
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
61 #define HK_PEERS_TREE 0x8000 /* peers connections events in tree mode */
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
62 /*
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
63 Default value is HK_ERRORS_TREE + HK_SNDRCV_TREE + HK_PEERS_TREE
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
64 */
1126
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
65
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
66 #include <freeDiameter/extension.h>
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
67
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
68 static struct fd_hook_hdl *md_hdl[4] = {NULL,NULL,NULL,NULL};
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
69 static uint32_t dump_level = HK_ERRORS_TREE | HK_SNDRCV_TREE | HK_PEERS_TREE; /* default */
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
70 static char * buf = NULL;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
71 static size_t len;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
72 static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
1126
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
73
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
74 /* The callback called when messages are received and sent */
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
75 static void md_hook_cb_tree(enum fd_hook_type type, struct msg * msg, struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, void * regdata)
1126
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
76 {
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
77 char * peer_name = peer ? peer->info.pi_diamid : "<unknown peer>";
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
78
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
79 CHECK_POSIX_DO( pthread_mutex_lock(&mtx), );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
80
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
81 if (msg) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
82 CHECK_MALLOC_DO( fd_msg_dump_treeview(&buf, &len, NULL, msg, fd_g_config->cnf_dict, (type == HOOK_MESSAGE_PARSING_ERROR) ? 0 : 1, 1),
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
83 { LOG_E("Error while dumping a message"); pthread_mutex_unlock(&mtx); return; } );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
84 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
85
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
86 switch (type) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
87 /* errors */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
88 case HOOK_MESSAGE_FAILOVER:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
89 LOG_E("FAILOVER from '%s':", peer_name);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
90 LOG_SPLIT(FD_LOG_ERROR, " ", buf, NULL);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
91 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
92 case HOOK_MESSAGE_PARSING_ERROR:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
93 if (msg) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
94 DiamId_t id = NULL;
1306
0d15dad33f0b Fix logic error when calling fd_msg_source_get().
Thomas Klausner <tk@giga.or.at>
parents: 1247
diff changeset
95 if (fd_msg_source_get( msg, &id, NULL ))
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
96 id = (DiamId_t)"<error getting source>";
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
97 if (!id)
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
98 id = (DiamId_t)"<local>";
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
99 LOG_E("PARSING ERROR: '%s' from '%s': ", (char *)other, (char *)id);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
100 LOG_SPLIT(FD_LOG_ERROR, " ", buf, NULL);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
101 } else {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
102 struct fd_cnx_rcvdata *rcv_data = other;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
103 CHECK_MALLOC_DO(fd_dump_extend_hexdump(&buf, &len, NULL, rcv_data->buffer, rcv_data->length, 0, 0), break);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
104 LOG_E("PARSING ERROR: %zdB msg from '%s': %s", rcv_data->length, peer_name, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
105 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
106 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
107 case HOOK_MESSAGE_ROUTING_ERROR:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
108 LOG_E("ROUTING ERROR '%s' for: ", (char *)other);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
109 LOG_SPLIT(FD_LOG_ERROR, " ", buf, NULL);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
110 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
111 case HOOK_MESSAGE_DROPPED:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
112 LOG_E("DROPPED '%s'", (char *)other);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
113 LOG_SPLIT(FD_LOG_ERROR, " ", buf, NULL);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
114 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
115
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
116 /* send receive */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
117 case HOOK_MESSAGE_RECEIVED:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
118 LOG_N("RCV from '%s':", peer_name);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
119 LOG_SPLIT(FD_LOG_NOTICE, " ", buf, NULL);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
120 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
121 case HOOK_MESSAGE_SENT:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
122 LOG_N("SND to '%s':", peer_name);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
123 LOG_SPLIT(FD_LOG_NOTICE, " ", buf, NULL);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
124 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
125
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
126 /* routing */
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
127 case HOOK_MESSAGE_LOCAL:
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
128 LOG_N("ISSUED:");
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
129 LOG_SPLIT(FD_LOG_NOTICE, " ", buf, NULL);
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
130 break;
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
131 case HOOK_MESSAGE_ROUTING_FORWARD:
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
132 LOG_N("FORWARDING: %s", buf);
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
133 LOG_SPLIT(FD_LOG_NOTICE, " ", buf, NULL);
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
134 break;
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
135 case HOOK_MESSAGE_ROUTING_LOCAL:
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
136 LOG_N("DISPATCHING: %s", buf);
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
137 LOG_SPLIT(FD_LOG_NOTICE, " ", buf, NULL);
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
138 break;
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
139
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
140 /* peers */
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
141 case HOOK_PEER_CONNECT_FAILED:
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
142 LOG_N("CONNECT FAILED to %s: %s", peer_name, (char *)other);
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
143 break;
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
144 case HOOK_PEER_CONNECT_SUCCESS:
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
145 {
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
146 char protobuf[40];
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
147 if (peer) {
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
148 CHECK_FCT_DO(fd_peer_cnx_proto_info(peer, protobuf, sizeof(protobuf)), break );
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
149 } else {
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
150 protobuf[0] = '-';
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
151 protobuf[1] = '\0';
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
152 }
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
153 LOG_N("CONNECTED TO '%s' (%s):", peer_name, protobuf);
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
154 LOG_SPLIT(FD_LOG_NOTICE, " ", buf, NULL);
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
155 }
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
156 break;
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
157
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
158 /* Not handled */
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
159 case HOOK_DATA_RECEIVED:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
160 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
161 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
162
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
163 CHECK_POSIX_DO( pthread_mutex_unlock(&mtx), );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
164 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
165
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
166 static void md_hook_cb_full(enum fd_hook_type type, struct msg * msg, struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, void * regdata)
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
167 {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
168 char * peer_name = peer ? peer->info.pi_diamid : "<unknown peer>";
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
169
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
170 CHECK_POSIX_DO( pthread_mutex_lock(&mtx), );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
171
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
172 if (msg) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
173 CHECK_MALLOC_DO( fd_msg_dump_full(&buf, &len, NULL, msg, fd_g_config->cnf_dict, (type == HOOK_MESSAGE_PARSING_ERROR) ? 0 : 1, 1),
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
174 { LOG_E("Error while dumping a message"); pthread_mutex_unlock(&mtx); return; } );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
175 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
176
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
177 switch (type) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
178 /* errors */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
179 case HOOK_MESSAGE_FAILOVER:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
180 LOG_E("FAILOVER from '%s': %s", peer_name, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
181 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
182 case HOOK_MESSAGE_PARSING_ERROR:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
183 if (msg) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
184 DiamId_t id = NULL;
1306
0d15dad33f0b Fix logic error when calling fd_msg_source_get().
Thomas Klausner <tk@giga.or.at>
parents: 1247
diff changeset
185 if (fd_msg_source_get( msg, &id, NULL ))
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
186 id = (DiamId_t)"<error getting source>";
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
187 if (!id)
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
188 id = (DiamId_t)"<local>";
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
189 LOG_E("PARSING ERROR: '%s' from '%s': %s", (char *)other, (char *)id, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
190 } else {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
191 struct fd_cnx_rcvdata *rcv_data = other;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
192 CHECK_MALLOC_DO(fd_dump_extend_hexdump(&buf, &len, NULL, rcv_data->buffer, rcv_data->length, 0, 0), break);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
193 LOG_E("PARSING ERROR: %zdB msg from '%s': %s", rcv_data->length, peer_name, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
194 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
195 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
196 case HOOK_MESSAGE_ROUTING_ERROR:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
197 LOG_E("ROUTING ERROR '%s' for: %s", (char *)other, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
198 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
199 case HOOK_MESSAGE_DROPPED:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
200 LOG_E("DROPPED '%s' %s", (char *)other, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
201 break;
1126
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
202
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
203 /* send receive */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
204 case HOOK_MESSAGE_RECEIVED:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
205 LOG_N("RCV from '%s': %s", peer_name, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
206 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
207 case HOOK_MESSAGE_SENT:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
208 LOG_N("SND to '%s': %s", peer_name, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
209 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
210
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
211 /* routing */
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
212 case HOOK_MESSAGE_LOCAL:
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
213 LOG_N("ISSUED: %s", buf);
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
214 break;
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
215 case HOOK_MESSAGE_ROUTING_FORWARD:
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
216 LOG_N("FORWARDING: %s", buf);
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
217 break;
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
218 case HOOK_MESSAGE_ROUTING_LOCAL:
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
219 LOG_N("DISPATCHING: %s", buf);
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
220 break;
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
221
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
222 /* peers */
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
223 case HOOK_PEER_CONNECT_FAILED:
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
224 LOG_N("CONNECT FAILED to %s: %s", peer_name, (char *)other);
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
225 break;
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
226 case HOOK_PEER_CONNECT_SUCCESS: {
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
227 char protobuf[40];
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
228 if (peer) {
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
229 CHECK_FCT_DO(fd_peer_cnx_proto_info(peer, protobuf, sizeof(protobuf)), break );
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
230 } else {
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
231 protobuf[0] = '-';
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
232 protobuf[1] = '\0';
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
233 }
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
234 LOG_N("CONNECTED TO '%s' (%s): %s", peer_name, protobuf, buf);
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
235 }
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
236 break;
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
237 /* Not handled */
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
238 case HOOK_DATA_RECEIVED:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
239 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
240 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
241
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
242 CHECK_POSIX_DO( pthread_mutex_unlock(&mtx), );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
243 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
244
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
245 static void md_hook_cb_compact(enum fd_hook_type type, struct msg * msg, struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, void * regdata)
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
246 {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
247 char * peer_name = peer ? peer->info.pi_diamid : "<unknown peer>";
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
248
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
249 CHECK_POSIX_DO( pthread_mutex_lock(&mtx), );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
250
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
251 if (msg) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
252 CHECK_MALLOC_DO( fd_msg_dump_summary(&buf, &len, NULL, msg, fd_g_config->cnf_dict, 0, 0),
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
253 { LOG_E("Error while dumping a message"); pthread_mutex_unlock(&mtx); return; } );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
254 }
1126
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
255
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
256 switch (type) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
257 /* errors */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
258 case HOOK_MESSAGE_FAILOVER:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
259 LOG_E("FAILOVER from '%s': %s", peer_name, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
260 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
261 case HOOK_MESSAGE_PARSING_ERROR:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
262 if (msg) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
263 DiamId_t id = NULL;
1306
0d15dad33f0b Fix logic error when calling fd_msg_source_get().
Thomas Klausner <tk@giga.or.at>
parents: 1247
diff changeset
264 if (fd_msg_source_get( msg, &id, NULL ))
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
265 id = (DiamId_t)"<error getting source>";
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
266 if (!id)
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
267 id = (DiamId_t)"<local>";
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
268 LOG_E("PARSING ERROR: '%s' from '%s': %s", (char *)other, (char *)id, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
269 } else {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
270 struct fd_cnx_rcvdata *rcv_data = other;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
271 CHECK_MALLOC_DO(fd_dump_extend_hexdump(&buf, &len, NULL, rcv_data->buffer, rcv_data->length, 0, 0), break);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
272 LOG_E("PARSING ERROR: %zdB msg from '%s': %s", rcv_data->length, peer_name, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
273 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
274 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
275 case HOOK_MESSAGE_ROUTING_ERROR:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
276 LOG_E("ROUTING ERROR '%s' for: %s", (char *)other, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
277 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
278 case HOOK_MESSAGE_DROPPED:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
279 LOG_E("DROPPED '%s' %s", (char *)other, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
280 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
281
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
282 /* send receive */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
283 case HOOK_MESSAGE_RECEIVED:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
284 LOG_N("RCV from '%s': %s", peer_name, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
285 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
286 case HOOK_MESSAGE_SENT:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
287 LOG_N("SND to '%s': %s", peer_name, buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
288 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
289
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
290 /* routing */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
291 case HOOK_MESSAGE_LOCAL:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
292 LOG_N("ISSUED: %s", buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
293 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
294 case HOOK_MESSAGE_ROUTING_FORWARD:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
295 LOG_N("FORWARDING: %s", buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
296 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
297 case HOOK_MESSAGE_ROUTING_LOCAL:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
298 LOG_N("DISPATCHING: %s", buf);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
299 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
300
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
301 /* peers */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
302 case HOOK_PEER_CONNECT_FAILED:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
303 LOG_N("CONNECT FAILED to %s: %s", peer_name, (char *)other);
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
304 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
305 case HOOK_PEER_CONNECT_SUCCESS: {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
306 char protobuf[40];
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
307 if (peer) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
308 CHECK_FCT_DO(fd_peer_cnx_proto_info(peer, protobuf, sizeof(protobuf)), break );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
309 } else {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
310 protobuf[0] = '-';
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
311 protobuf[1] = '\0';
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
312 }
1247
2c09e2545188 Remove useless CER/CEA compact dump in dbg_msg_dumps extension
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1245
diff changeset
313 LOG_N("CONNECTED TO '%s' (%s)", peer_name, protobuf);
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
314 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
315 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
316 /* Not handled */
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
317 case HOOK_DATA_RECEIVED:
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
318 break;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
319 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
320
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
321 CHECK_POSIX_DO( pthread_mutex_unlock(&mtx), );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
322 }
1126
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
323
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
324 static void md_hook_cb_quiet(enum fd_hook_type type, struct msg * msg, struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, void * regdata)
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
325 {
1126
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
326 }
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
327
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
328 /* Entry point */
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
329 static int md_main(char * conffile)
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
330 {
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
331 uint32_t mask_errors, mask_sndrcv, mask_routing, mask_peers;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
332 uint32_t mask_quiet, mask_compact, mask_full, mask_tree;
1126
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
333 TRACE_ENTRY("%p", conffile);
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
334
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
335 if (conffile != NULL) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
336 char * endp;
1244
24a03140a6aa Bug: parameters for peers were not taken into account
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1204
diff changeset
337 dump_level = (uint32_t)strtoul(conffile, &endp, 16);
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
338 CHECK_PARAMS_DO( *endp == '\0', {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
339 LOG_E("Configuration parameter must be in the form \"0xNNNN\"");
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
340 return EINVAL; });
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
341 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
342
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
343 mask_errors = HOOK_MASK( HOOK_MESSAGE_FAILOVER, HOOK_MESSAGE_PARSING_ERROR, HOOK_MESSAGE_ROUTING_ERROR, HOOK_MESSAGE_DROPPED );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
344 mask_sndrcv = HOOK_MASK( HOOK_MESSAGE_RECEIVED, HOOK_MESSAGE_SENT );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
345 mask_routing= HOOK_MASK( HOOK_MESSAGE_LOCAL, HOOK_MESSAGE_ROUTING_FORWARD, HOOK_MESSAGE_ROUTING_LOCAL );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
346 mask_peers = HOOK_MASK( HOOK_PEER_CONNECT_FAILED, HOOK_PEER_CONNECT_SUCCESS );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
347
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
348 mask_quiet = (dump_level & HK_ERRORS_QUIET) ? mask_errors : 0;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
349 mask_quiet |= (dump_level & HK_SNDRCV_QUIET) ? mask_sndrcv : 0;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
350 mask_quiet |= (dump_level & HK_ROUTING_QUIET) ? mask_routing : 0;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
351 mask_quiet |= (dump_level & HK_PEERS_QUIET) ? mask_peers : 0;
1126
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
352
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
353 mask_compact = (dump_level & HK_ERRORS_COMPACT) ? mask_errors : 0;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
354 mask_compact |= (dump_level & HK_SNDRCV_COMPACT) ? mask_sndrcv : 0;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
355 mask_compact |= (dump_level & HK_ROUTING_COMPACT) ? mask_routing : 0;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
356 mask_compact |= (dump_level & HK_PEERS_COMPACT) ? mask_peers : 0;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
357
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
358 mask_full = (dump_level & HK_ERRORS_FULL) ? mask_errors : 0;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
359 mask_full |= (dump_level & HK_SNDRCV_FULL) ? mask_sndrcv : 0;
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
360 mask_full |= (dump_level & HK_ROUTING_FULL) ? mask_routing : 0;
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
361 mask_full |= (dump_level & HK_PEERS_FULL) ? mask_peers : 0;
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
362
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
363 mask_tree = (dump_level & HK_ERRORS_TREE) ? mask_errors : 0;
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
364 mask_tree |= (dump_level & HK_SNDRCV_TREE) ? mask_sndrcv : 0;
1245
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
365 mask_tree |= (dump_level & HK_ROUTING_TREE) ? mask_routing : 0;
4b511d9b3def Change default dump of peer connection, add more options to the dbg_msg_dumps extensions
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1244
diff changeset
366 mask_tree |= (dump_level & HK_PEERS_TREE) ? mask_peers : 0;
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
367
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
368 if (mask_quiet) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
369 CHECK_FCT( fd_hook_register( mask_quiet, md_hook_cb_quiet, NULL, NULL, &md_hdl[0]) );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
370 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
371 if (mask_compact) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
372 CHECK_FCT( fd_hook_register( mask_compact, md_hook_cb_compact, NULL, NULL, &md_hdl[1]) );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
373 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
374 if (mask_full) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
375 CHECK_FCT( fd_hook_register( mask_full, md_hook_cb_full, NULL, NULL, &md_hdl[2]) );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
376 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
377 if (mask_tree) {
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
378 CHECK_FCT( fd_hook_register( mask_tree, md_hook_cb_tree, NULL, NULL, &md_hdl[3]) );
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
379 }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
380
1126
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
381 return 0;
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
382 }
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
383
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
384 /* Cleanup */
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
385 void fd_ext_fini(void)
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
386 {
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
387 TRACE_ENTRY();
1204
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
388 if (md_hdl[0]) { CHECK_FCT_DO( fd_hook_unregister( md_hdl[0] ), ); }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
389 if (md_hdl[1]) { CHECK_FCT_DO( fd_hook_unregister( md_hdl[1] ), ); }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
390 if (md_hdl[2]) { CHECK_FCT_DO( fd_hook_unregister( md_hdl[2] ), ); }
a4cdde705f30 Add options to dbg_msg_dumps.fdx to allow more control over the behavior
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1168
diff changeset
391 if (md_hdl[2]) { CHECK_FCT_DO( fd_hook_unregister( md_hdl[3] ), ); }
1126
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
392 return ;
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
393 }
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
394
d6e18ebca0c5 New extension dbg_msg_dumps for debug / learning.
Sebastien Decugis <sdecugis@freediameter.net>
parents:
diff changeset
395 EXTENSION_ENTRY("dbg_msg_dumps", md_main);
"Welcome to our mercurial repository"