diff options
author | Bart Polot <bart@net.in.tum.de> | 2014-01-30 02:11:10 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2014-01-30 02:11:10 +0000 |
commit | f2048c2995b10d2099561eefcd140f5ba096044c (patch) | |
tree | 2b7ce322ffac1e18c5cb963713d456367ccc0571 /src | |
parent | 479d372eba76ec3ebda8acb42a6f23e07009e381 (diff) | |
download | gnunet-f2048c2995b10d2099561eefcd140f5ba096044c.tar.gz gnunet-f2048c2995b10d2099561eefcd140f5ba096044c.zip |
- fix show tunnel
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/mesh_api.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index c190d8e30..c1088054a 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c | |||
@@ -1088,39 +1088,44 @@ process_get_tunnel (struct GNUNET_MESH_Handle *h, | |||
1088 | { | 1088 | { |
1089 | struct GNUNET_MESH_LocalInfoTunnel *msg; | 1089 | struct GNUNET_MESH_LocalInfoTunnel *msg; |
1090 | size_t esize; | 1090 | size_t esize; |
1091 | size_t msize; | ||
1091 | 1092 | ||
1092 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Get Tunnel messasge received\n"); | 1093 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Get Tunnel messasge received\n"); |
1093 | |||
1094 | if (NULL == h->tunnel_cb) | 1094 | if (NULL == h->tunnel_cb) |
1095 | { | 1095 | { |
1096 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " ignored\n"); | 1096 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ignored\n"); |
1097 | return; | 1097 | return; |
1098 | } | 1098 | } |
1099 | 1099 | ||
1100 | /* Verify message sanity */ | 1100 | /* Verify message sanity */ |
1101 | msg = (struct GNUNET_MESH_LocalInfoTunnel *) message; | 1101 | msg = (struct GNUNET_MESH_LocalInfoTunnel *) message; |
1102 | esize = sizeof (struct GNUNET_MESH_LocalInfo); | 1102 | msize = ntohs (message->size); |
1103 | if (ntohs (message->size) != esize) | 1103 | esize = sizeof (struct GNUNET_MESH_LocalInfoTunnel); |
1104 | if (esize > msize) | ||
1104 | { | 1105 | { |
1105 | GNUNET_break_op (0); | 1106 | GNUNET_break_op (0); |
1106 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1107 | "Get Tunnel message: size %hu - expected %u\n", | ||
1108 | ntohs (message->size), | ||
1109 | esize); | ||
1110 | |||
1111 | h->tunnel_cb (h->tunnel_cls, NULL, 0, 0, 0, 0); | 1107 | h->tunnel_cb (h->tunnel_cls, NULL, 0, 0, 0, 0); |
1112 | h->tunnel_cb = NULL; | 1108 | goto clean_cls; |
1113 | h->tunnel_cls = NULL; | 1109 | } |
1114 | 1110 | esize += ntohl (msg->connections) * sizeof (struct GNUNET_HashCode); | |
1115 | return; | 1111 | esize += ntohl (msg->channels) * sizeof (MESH_ChannelNumber); |
1112 | if (msize != esize) | ||
1113 | { | ||
1114 | GNUNET_break_op (0); | ||
1115 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "e: %u, m:%u\n", esize, msize); | ||
1116 | h->tunnel_cb (h->tunnel_cls, NULL, 0, 0, 0, 0); | ||
1117 | goto clean_cls; | ||
1116 | } | 1118 | } |
1117 | 1119 | ||
1120 | /* Call Callback with tunnel info. */ | ||
1118 | h->tunnel_cb (h->tunnel_cls, | 1121 | h->tunnel_cb (h->tunnel_cls, |
1119 | &msg->destination, | 1122 | &msg->destination, |
1120 | ntohl (msg->channels), | 1123 | ntohl (msg->channels), |
1121 | ntohl (msg->connections), | 1124 | ntohl (msg->connections), |
1122 | ntohl (msg->estate), | 1125 | ntohl (msg->estate), |
1123 | ntohl (msg->cstate)); | 1126 | ntohl (msg->cstate)); |
1127 | |||
1128 | clean_cls: | ||
1124 | h->tunnel_cb = NULL; | 1129 | h->tunnel_cb = NULL; |
1125 | h->tunnel_cls = NULL; | 1130 | h->tunnel_cls = NULL; |
1126 | } | 1131 | } |