aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_wlan.c
diff options
context:
space:
mode:
authorDavid Brodski <david@brodski.eu>2011-09-13 08:22:18 +0000
committerDavid Brodski <david@brodski.eu>2011-09-13 08:22:18 +0000
commite19ba71ebc4b8a5b14e42c7632acc2f46988f650 (patch)
tree70ff801dea6d20c45efbc6051dd8b1315baeeca6 /src/transport/plugin_transport_wlan.c
parent983b7b09169634e585949bf4d5e09336cbf76afc (diff)
downloadgnunet-e19ba71ebc4b8a5b14e42c7632acc2f46988f650.tar.gz
gnunet-e19ba71ebc4b8a5b14e42c7632acc2f46988f650.zip
msg dump on error if needed
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r--src/transport/plugin_transport_wlan.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index f75e507a4..fa638ac0f 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -93,9 +93,10 @@
93/** 93/**
94 * DEBUG switch 94 * DEBUG switch
95 */ 95 */
96#define DEBUG_wlan GNUNET_YES 96#define DEBUG_wlan GNUNET_NO
97#define DEBUG_wlan_retransmission GNUNET_NO 97#define DEBUG_wlan_retransmission GNUNET_NO
98#define DEBUG_wlan_ip_udp_packets_on_air GNUNET_NO 98#define DEBUG_wlan_ip_udp_packets_on_air GNUNET_NO
99#define DEBUG_wlan_msg_dump GNUNET_NO
99 100
100 101
101#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ 102#define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */
@@ -678,8 +679,8 @@ create_macendpoint (struct Plugin *plugin, const struct MacAddress *addr);
678 * \param mem pointer to memory to dump 679 * \param mem pointer to memory to dump
679 * \param length how many bytes to dump 680 * \param length how many bytes to dump
680 */ 681 */
681void 682static void
682hexdump (void *mem, unsigned length) 683hexdump (const void *mem, unsigned length)
683{ 684{
684 char line[80]; 685 char line[80];
685 char *src = (char *) mem; 686 char *src = (char *) mem;
@@ -758,10 +759,10 @@ get_macendpoint (struct Plugin *plugin, const struct MacAddress *addr,
758} 759}
759 760
760/** 761/**
761 * search for a session with the address and peer id 762 * search for a session with the macendpoint and peer id
762 * 763 *
763 * @param plugin pointer to the plugin struct 764 * @param plugin pointer to the plugin struct
764 * @param addr pointer to the mac address of the peer 765 * @param endpoint pointer to the mac endpoint of the peer
765 * @param peer pointer to the peerid 766 * @param peer pointer to the peerid
766 * @return returns the session 767 * @return returns the session
767 */ 768 */
@@ -846,7 +847,8 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
846 * create a new session 847 * create a new session
847 * 848 *
848 * @param plugin pointer to the plugin struct 849 * @param plugin pointer to the plugin struct
849 * @param addr pointer to the mac endpoint of the peer 850 * @param endpoint pointer to the mac endpoint of the peer
851 * @param peer peer identity to use for this session
850 * @return returns the session 852 * @return returns the session
851 */ 853 */
852 854
@@ -1226,6 +1228,7 @@ getRadiotapHeader (struct Plugin *plugin, struct MacEndpoint *endpoint,
1226 * @param Header address to write the header to 1228 * @param Header address to write the header to
1227 * @param to_mac_addr address of the recipient 1229 * @param to_mac_addr address of the recipient
1228 * @param plugin pointer to the plugin struct 1230 * @param plugin pointer to the plugin struct
1231 * @param size size of the whole packet, needed to calculate the time to send the packet
1229 * @return GNUNET_YES if there was no error 1232 * @return GNUNET_YES if there was no error
1230 */ 1233 */
1231static int 1234static int
@@ -1336,8 +1339,8 @@ add_message_for_send (void *cls, const struct GNUNET_MessageHeader *hdr)
1336 1339
1337#if DEBUG_wlan_retransmission 1340#if DEBUG_wlan_retransmission
1338 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, 1341 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1339 "Adding fragment of message %p to send, session %p, endpoint %p\n", 1342 "Adding fragment of message %p to send, session %p, endpoint %p, type %u\n",
1340 fm, fm->session, endpoint); 1343 fm, fm->session, endpoint, hdr->type);
1341#endif 1344#endif
1342 1345
1343 size = 1346 size =
@@ -1901,7 +1904,9 @@ wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
1901 "New message for %p with size (incl wlan header) %u added\n", 1904 "New message for %p with size (incl wlan header) %u added\n",
1902 session, newmsg->message_size); 1905 session, newmsg->message_size);
1903#endif 1906#endif
1904 1907#if DEBUG_wlan_msg_dump
1908 hexdump(msgbuf,GNUNET_MIN(msgbuf_size, 256));
1909#endif
1905 //queue session 1910 //queue session
1906 queue_session (plugin, session); 1911 queue_session (plugin, session);
1907 1912
@@ -1914,7 +1919,7 @@ wlan_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
1914/** 1919/**
1915 * function to free a mac endpoint 1920 * function to free a mac endpoint
1916 * @param plugin pointer to the plugin struct 1921 * @param plugin pointer to the plugin struct
1917 * @param endpoin pointer to the MacEndpoint to free 1922 * @param endpoint pointer to the MacEndpoint to free
1918 */ 1923 */
1919static void 1924static void
1920free_macendpoint (struct Plugin *plugin, struct MacEndpoint *endpoint) 1925free_macendpoint (struct Plugin *plugin, struct MacEndpoint *endpoint)
@@ -2099,8 +2104,7 @@ wlan_plugin_address_pretty_printer (void *cls, const char *type,
2099 2104
2100/** 2105/**
2101 * handels the data after all fragments are put together 2106 * handels the data after all fragments are put together
2102 * @param plugin 2107 * @param cls macendpoint this messages belongs to
2103 * @param session_light
2104 * @param hdr pointer to the data 2108 * @param hdr pointer to the data
2105 */ 2109 */
2106static void 2110static void
@@ -2235,7 +2239,7 @@ wlan_data_message_handler (void *cls, const struct GNUNET_MessageHeader *hdr)
2235 else 2239 else
2236 { 2240 {
2237 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, PLUGIN_LOG_NAME, 2241 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, PLUGIN_LOG_NAME,
2238 "wlan_data_message_handler got wrong message type\n"); 2242 "wlan_data_message_handler got wrong message type: %u\n", ntohs (hdr->size));
2239 return; 2243 return;
2240 } 2244 }
2241} 2245}
@@ -2639,7 +2643,6 @@ wlan_process_helper (void *cls, void *client,
2639 break; 2643 break;
2640 case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL: 2644 case GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL:
2641 //TODO more control messages 2645 //TODO more control messages
2642 //TODO use struct wlan_helper_control
2643 if (ntohs (hdr->size) != sizeof (struct Wlan_Helper_Control_Message)) 2646 if (ntohs (hdr->size) != sizeof (struct Wlan_Helper_Control_Message))
2644 { 2647 {
2645 GNUNET_break (0); 2648 GNUNET_break (0);
@@ -2664,6 +2667,10 @@ wlan_process_helper (void *cls, void *client,
2664 "Func wlan_process_helper got unknown message with number %u, size %u\n", 2667 "Func wlan_process_helper got unknown message with number %u, size %u\n",
2665 ntohs (hdr->type), 2668 ntohs (hdr->type),
2666 ntohs (hdr->size)); 2669 ntohs (hdr->size));
2670
2671#endif
2672#if DEBUG_wlan_msg_dump
2673 hexdump(hdr,GNUNET_MIN(ntohs (hdr->size), 256));
2667#endif 2674#endif
2668 GNUNET_break (0); 2675 GNUNET_break (0);
2669 return; 2676 return;