Messages.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (c) 2009, 2020 IBM Corp.
3  *
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v2.0
6  * and Eclipse Distribution License v1.0 which accompany this distribution.
7  *
8  * The Eclipse Public License is available at
9  * https://www.eclipse.org/legal/epl-2.0/
10  * and the Eclipse Distribution License is available at
11  * http://www.eclipse.org/org/documents/edl-v10.php.
12  *
13  * Contributors:
14  * Ian Craggs - initial API and implementation and/or initial documentation
15  *******************************************************************************/
16 
24 #include "Messages.h"
25 #include "Log.h"
26 
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 
31 #include "Heap.h"
32 
33 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
34 
35 #define max_msg_len 120
36 
37 static const char *protocol_message_list[] =
38 {
39  "%d %s -> CONNECT version %d clean: %d (%d)", /* 0, was 131, 68 and 69 */
40  "%d %s <- CONNACK rc: %d", /* 1, was 132 */
41  "%d %s -> CONNACK rc: %d (%d)", /* 2, was 138 */
42  "%d %s <- PINGREQ", /* 3, was 35 */
43  "%d %s -> PINGRESP (%d)", /* 4 */
44  "%d %s <- DISCONNECT", /* 5 */
45  "%d %s <- SUBSCRIBE msgid: %d", /* 6, was 39 */
46  "%d %s -> SUBACK msgid: %d (%d)", /* 7, was 40 */
47  "%d %s <- UNSUBSCRIBE msgid: %d", /* 8, was 41 */
48  "%d %s -> UNSUBACK msgid: %d (%d)", /* 9 */
49  "%d %s -> PUBLISH msgid: %d qos: %d retained: %d rc %d payload len(%d): %.*s", /* 10, was 42 */
50  "%d %s <- PUBLISH msgid: %d qos: %d retained: %d payload len(%d): %.*s", /* 11, was 46 */
51  "%d %s -> PUBACK msgid: %d (%d)", /* 12, was 47 */
52  "%d %s -> PUBREC msgid: %d (%d)", /* 13, was 48 */
53  "%d %s <- PUBACK msgid: %d", /* 14, was 49 */
54  "%d %s <- PUBREC msgid: %d", /* 15, was 53 */
55  "%d %s -> PUBREL msgid: %d (%d)", /* 16, was 57 */
56  "%d %s <- PUBREL msgid %d", /* 17, was 58 */
57  "%d %s -> PUBCOMP msgid %d (%d)", /* 18, was 62 */
58  "%d %s <- PUBCOMP msgid:%d", /* 19, was 63 */
59  "%d %s -> PINGREQ (%d)", /* 20, was 137 */
60  "%d %s <- PINGRESP", /* 21, was 70 */
61  "%d %s -> SUBSCRIBE msgid: %d (%d)", /* 22, was 72 */
62  "%d %s <- SUBACK msgid: %d", /* 23, was 73 */
63  "%d %s <- UNSUBACK msgid: %d", /* 24, was 74 */
64  "%d %s -> UNSUBSCRIBE msgid: %d (%d)", /* 25, was 106 */
65  "%d %s <- CONNECT", /* 26 */
66  "%d %s -> PUBLISH qos: 0 retained: %d rc: %d payload len(%d): %.*s", /* 27 */
67  "%d %s -> DISCONNECT (%d)", /* 28 */
68  "Socket error for client identifier %s, socket %d, peer address %s; ending connection", /* 29 */
69 };
70 
71 static const char *trace_message_list[] =
72 {
73  "Failed to remove client from bstate->clients", /* 0 */
74  "Removed client %s from bstate->clients, socket %d", /* 1 */
75  "Packet_Factory: unhandled packet type %d", /* 2 */
76  "Packet %s received from client %s for message identifier %d, but no record of that message identifier found", /* 3 */
77  "Packet %s received from client %s for message identifier %d, but message is wrong QoS, %d", /* 4 */
78  "Packet %s received from client %s for message identifier %d, but message is in wrong state", /* 5 */
79  "%s received from client %s for message id %d - removing publication", /* 6 */
80  "Trying %s again for client %s, socket %d, message identifier %d", /* 7 */
81  "", /* 8 */
82  "(%lu) %*s(%d)> %s:%d", /* 9 */
83  "(%lu) %*s(%d)< %s:%d", /* 10 */
84  "(%lu) %*s(%d)< %s:%d (%d)", /* 11 */
85  "Storing unsent QoS 0 message", /* 12 */
86 };
87 
94 const char* Messages_get(int index, enum LOG_LEVELS log_level)
95 {
96  const char *msg = NULL;
97 
98  if (log_level == TRACE_PROTOCOL)
99  msg = (index >= 0 && index < ARRAY_SIZE(protocol_message_list)) ? protocol_message_list[index] : NULL;
100  else
101  msg = (index >= 0 && index < ARRAY_SIZE(trace_message_list)) ? trace_message_list[index] : NULL;
102  return msg;
103 }
104 
LOG_LEVELS
Definition: Log.h:35
static const char * protocol_message_list[]
Definition: Messages.c:37
const char * Messages_get(int index, enum LOG_LEVELS log_level)
Definition: Messages.c:94
#define ARRAY_SIZE(a)
Definition: Messages.c:33
static const char * trace_message_list[]
Definition: Messages.c:71


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:09