diff options
Diffstat (limited to 'src/transport/gnunet-helper-transport-wlan-dummy.c')
-rw-r--r-- | src/transport/gnunet-helper-transport-wlan-dummy.c | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/src/transport/gnunet-helper-transport-wlan-dummy.c b/src/transport/gnunet-helper-transport-wlan-dummy.c index 3f17b04dd..cd545af65 100644 --- a/src/transport/gnunet-helper-transport-wlan-dummy.c +++ b/src/transport/gnunet-helper-transport-wlan-dummy.c | |||
@@ -77,49 +77,35 @@ static void | |||
77 | stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | 77 | stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) |
78 | { | 78 | { |
79 | struct sendbuf *write_pout = cls; | 79 | struct sendbuf *write_pout = cls; |
80 | int sendsize; | 80 | const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *in; |
81 | struct GNUNET_MessageHeader newheader; | 81 | size_t payload_size; |
82 | char *to_data; | 82 | struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage newheader; |
83 | char *to_radiotap; | ||
84 | char *to_start; | ||
85 | 83 | ||
86 | sendsize = | 84 | in = (const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) hdr; |
87 | ntohs (hdr->size) - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) + | 85 | if ( (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA != ntohs (hdr->type)) || |
88 | sizeof (struct Radiotap_rx) + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame) + | 86 | (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) < ntohs (hdr->size)) ) |
89 | sizeof (struct GNUNET_MessageHeader); | ||
90 | |||
91 | if (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA != ntohs (hdr->type)) | ||
92 | { | 87 | { |
93 | fprintf (stderr, "Function stdin_send: wrong packet type\n"); | 88 | fprintf (stderr, "Function stdin_send: wrong packet type or size\n"); |
94 | exit (1); | 89 | exit (1); |
95 | } | 90 | } |
96 | if ((sendsize + write_pout->size) > MAXLINE * 2) | 91 | payload_size = ntohs (hdr->size) - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage); |
92 | if ((payload_size + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) + write_pout->size) > MAXLINE * 2) | ||
97 | { | 93 | { |
98 | fprintf (stderr, "Function stdin_send: Packet too big for buffer\n"); | 94 | fprintf (stderr, "Function stdin_send: Packet too big for buffer\n"); |
99 | exit (1); | 95 | exit (1); |
100 | } | 96 | } |
101 | 97 | memset (&newheader, 0, sizeof (newheader)); | |
102 | newheader.size = htons (sendsize); | 98 | newheader.header.size = htons (payload_size + sizeof (newheader)); |
103 | newheader.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA); | 99 | newheader.header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA); |
104 | 100 | newheader.frame = in->frame; | |
105 | to_start = write_pout->buf + write_pout->size; | 101 | memcpy (write_pout->buf + write_pout->size, |
106 | memcpy (to_start, &newheader, sizeof (struct GNUNET_MessageHeader)); | 102 | &newheader, |
107 | write_pout->size += sizeof (struct GNUNET_MessageHeader); | 103 | sizeof (newheader)); |
108 | 104 | write_pout->size += sizeof (newheader); | |
109 | to_radiotap = to_start + sizeof (struct GNUNET_MessageHeader); | 105 | memcpy (write_pout->buf + write_pout->size, |
110 | memset (to_radiotap, 0, sizeof (struct Radiotap_rx)); | 106 | &in[1], |
111 | write_pout->size += sizeof (struct Radiotap_rx); | 107 | payload_size); |
112 | 108 | write_pout->size += payload_size; | |
113 | to_data = to_radiotap + sizeof (struct Radiotap_rx); | ||
114 | memcpy (to_data, | ||
115 | ((char *) hdr) + | ||
116 | sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) - | ||
117 | - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame), | ||
118 | ntohs (hdr->size) - (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) | ||
119 | - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame))); | ||
120 | write_pout->size += | ||
121 | ntohs (hdr->size) - (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) | ||
122 | - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame)); | ||
123 | } | 109 | } |
124 | 110 | ||
125 | 111 | ||