diff options
author | David Brodski <david@brodski.eu> | 2011-09-13 06:59:16 +0000 |
---|---|---|
committer | David Brodski <david@brodski.eu> | 2011-09-13 06:59:16 +0000 |
commit | 0e5be9c9ffb67542bd41257a7a2fe2384f448106 (patch) | |
tree | 8fe49efb4976db3374b7ee5eecae121125671673 /src/transport | |
parent | 05680649d9fe7b4a6fc54031cada1aeca0e55db1 (diff) | |
download | gnunet-0e5be9c9ffb67542bd41257a7a2fe2384f448106.tar.gz gnunet-0e5be9c9ffb67542bd41257a7a2fe2384f448106.zip |
Big cleanup, less source files
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/gnunet-transport-wlan-helper.c | 169 | ||||
-rw-r--r-- | src/transport/gnunet-transport-wlan-helper.h | 14 | ||||
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 21 | ||||
-rw-r--r-- | src/transport/test_plugin_transport_wlan_dummy.c | 10 | ||||
-rw-r--r-- | src/transport/wlan/helper_common.c | 79 | ||||
-rw-r--r-- | src/transport/wlan/helper_common.h | 14 | ||||
-rw-r--r-- | src/transport/wlan/loopback_helper.h | 6 |
7 files changed, 192 insertions, 121 deletions
diff --git a/src/transport/gnunet-transport-wlan-helper.c b/src/transport/gnunet-transport-wlan-helper.c index ad6810233..7717966dc 100644 --- a/src/transport/gnunet-transport-wlan-helper.c +++ b/src/transport/gnunet-transport-wlan-helper.c | |||
@@ -80,19 +80,72 @@ | |||
80 | */ | 80 | */ |
81 | #include "wlan/ieee80211_radiotap.h" | 81 | #include "wlan/ieee80211_radiotap.h" |
82 | #include "wlan/crctable_osdep.h" | 82 | #include "wlan/crctable_osdep.h" |
83 | #include "wlan/loopback_helper.h" | 83 | //#include "wlan/loopback_helper.h" |
84 | #include "wlan/ieee80211.h" | 84 | //#include "wlan/ieee80211.h" |
85 | #include "wlan/helper_common.h" | ||
85 | 86 | ||
86 | #define ARPHRD_IEEE80211 801 | 87 | #define ARPHRD_IEEE80211 801 |
87 | #define ARPHRD_IEEE80211_PRISM 802 | 88 | #define ARPHRD_IEEE80211_PRISM 802 |
88 | #define ARPHRD_IEEE80211_FULL 803 | 89 | #define ARPHRD_IEEE80211_FULL 803 |
89 | 90 | ||
90 | #include "wlan/loopback_helper.h" | ||
91 | |||
92 | #define DEBUG 1 | 91 | #define DEBUG 1 |
93 | 92 | ||
94 | #define MAC_ADDR_SIZE 6 | 93 | #define MAC_ADDR_SIZE 6 |
95 | 94 | ||
95 | //Part taken from file ieee80211.h | ||
96 | /*- | ||
97 | * Copyright (c) 2001 Atsushi Onoe | ||
98 | * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting | ||
99 | * All rights reserved. | ||
100 | * | ||
101 | * Redistribution and use in source and binary forms, with or without | ||
102 | * modification, are permitted provided that the following conditions | ||
103 | * are met: | ||
104 | * 1. Redistributions of source code must retain the above copyright | ||
105 | * notice, this list of conditions and the following disclaimer. | ||
106 | * 2. Redistributions in binary form must reproduce the above copyright | ||
107 | * notice, this list of conditions and the following disclaimer in the | ||
108 | * documentation and/or other materials provided with the distribution. | ||
109 | * 3. The name of the author may not be used to endorse or promote products | ||
110 | * derived from this software without specific prior written permission. | ||
111 | * | ||
112 | * Alternatively, this software may be distributed under the terms of the | ||
113 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
114 | * Software Foundation. | ||
115 | * | ||
116 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
117 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
118 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
119 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
120 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
121 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
122 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
123 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
124 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
125 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
126 | * | ||
127 | * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.12 2006/12/01 18:40:51 imp Exp $ | ||
128 | */ | ||
129 | |||
130 | #define IEEE80211_ADDR_LEN 6 /* size of 802.11 address */ | ||
131 | |||
132 | /* | ||
133 | * generic definitions for IEEE 802.11 frames | ||
134 | */ | ||
135 | struct ieee80211_frame | ||
136 | { | ||
137 | u_int8_t i_fc[2]; | ||
138 | u_int8_t i_dur[2]; | ||
139 | u_int8_t i_addr1[IEEE80211_ADDR_LEN]; | ||
140 | u_int8_t i_addr2[IEEE80211_ADDR_LEN]; | ||
141 | u_int8_t i_addr3[IEEE80211_ADDR_LEN]; | ||
142 | u_int8_t i_seq[2]; | ||
143 | /* possibly followed by addr4[IEEE80211_ADDR_LEN]; */ | ||
144 | /* see below */ | ||
145 | } GNUNET_PACKED; | ||
146 | |||
147 | // End taken part | ||
148 | |||
96 | struct Hardware_Infos | 149 | struct Hardware_Infos |
97 | { | 150 | { |
98 | 151 | ||
@@ -107,6 +160,14 @@ struct Hardware_Infos | |||
107 | unsigned char pl_mac[MAC_ADDR_SIZE]; | 160 | unsigned char pl_mac[MAC_ADDR_SIZE]; |
108 | }; | 161 | }; |
109 | 162 | ||
163 | struct RadioTapheader | ||
164 | { | ||
165 | struct ieee80211_radiotap_header header; | ||
166 | u8 rate; | ||
167 | u8 pad1; | ||
168 | u16 txflags; | ||
169 | }; | ||
170 | |||
110 | // FIXME: inline? | 171 | // FIXME: inline? |
111 | int | 172 | int |
112 | getChannelFromFrequency (int frequency); | 173 | getChannelFromFrequency (int frequency); |
@@ -126,6 +187,7 @@ calc_crc_osdep (unsigned char *buf, int len) | |||
126 | /* CRC checksum verification routine */ | 187 | /* CRC checksum verification routine */ |
127 | 188 | ||
128 | // FIXME: make nice... | 189 | // FIXME: make nice... |
190 | // fixme doxigen | ||
129 | static int | 191 | static int |
130 | check_crc_buf_osdep (unsigned char *buf, int len) | 192 | check_crc_buf_osdep (unsigned char *buf, int len) |
131 | { | 193 | { |
@@ -142,6 +204,7 @@ check_crc_buf_osdep (unsigned char *buf, int len) | |||
142 | 204 | ||
143 | 205 | ||
144 | // FIXME: make nice... | 206 | // FIXME: make nice... |
207 | //fixme doxigen | ||
145 | static int | 208 | static int |
146 | linux_get_channel (struct Hardware_Infos *dev) | 209 | linux_get_channel (struct Hardware_Infos *dev) |
147 | { | 210 | { |
@@ -173,6 +236,7 @@ linux_get_channel (struct Hardware_Infos *dev) | |||
173 | 236 | ||
174 | 237 | ||
175 | // FIXME: make nice... | 238 | // FIXME: make nice... |
239 | //FIXME doxigen | ||
176 | static ssize_t | 240 | static ssize_t |
177 | linux_read (struct Hardware_Infos *dev, unsigned char *buf, /* FIXME: void*? */ | 241 | linux_read (struct Hardware_Infos *dev, unsigned char *buf, /* FIXME: void*? */ |
178 | size_t buf_size, struct Radiotap_rx *ri) | 242 | size_t buf_size, struct Radiotap_rx *ri) |
@@ -356,7 +420,7 @@ linux_read (struct Hardware_Infos *dev, unsigned char *buf, /* FIXME: void*? | |||
356 | return caplen; | 420 | return caplen; |
357 | } | 421 | } |
358 | 422 | ||
359 | 423 | //FIXME doxigen | |
360 | /** | 424 | /** |
361 | * @return 0 on success | 425 | * @return 0 on success |
362 | */ | 426 | */ |
@@ -551,14 +615,7 @@ mac_set (struct ieee80211_frame *u8aIeeeHeader, | |||
551 | 615 | ||
552 | } | 616 | } |
553 | 617 | ||
554 | struct RadioTapheader | 618 | //FIXME: doxigen |
555 | { | ||
556 | struct ieee80211_radiotap_header header; | ||
557 | u8 rate; | ||
558 | u8 pad1; | ||
559 | u16 txflags; | ||
560 | }; | ||
561 | |||
562 | static void | 619 | static void |
563 | stdin_send_hw (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | 620 | stdin_send_hw (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) |
564 | { | 621 | { |
@@ -590,7 +647,7 @@ stdin_send_hw (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
590 | if (sendsize < | 647 | if (sendsize < |
591 | sizeof (struct Radiotap_Send) + sizeof (struct GNUNET_MessageHeader)) | 648 | sizeof (struct Radiotap_Send) + sizeof (struct GNUNET_MessageHeader)) |
592 | { | 649 | { |
593 | fprintf (stderr, "Function stdin_send_hw: mailformed packet (too small)\n"); | 650 | fprintf (stderr, "Function stdin_send_hw: malformed packet (too small)\n"); |
594 | exit (1); | 651 | exit (1); |
595 | } | 652 | } |
596 | sendsize -= | 653 | sendsize -= |
@@ -705,19 +762,21 @@ maketest (unsigned char *buf, struct Hardware_Infos *dev) | |||
705 | * @return number of bytes written | 762 | * @return number of bytes written |
706 | */ | 763 | */ |
707 | // FIXME: use 'struct MacAddress' for 'mac' (everywhere in this file) | 764 | // FIXME: use 'struct MacAddress' for 'mac' (everywhere in this file) |
765 | /* | ||
708 | static int | 766 | static int |
709 | send_mac_to_plugin (char *buffer, uint8_t * mac) | 767 | send_mac_to_plugin (char *buffer, struct MacAddress * mac) |
710 | { | 768 | { |
711 | struct Wlan_Helper_Control_Message macmsg; | 769 | struct Wlan_Helper_Control_Message macmsg; |
712 | 770 | ||
713 | macmsg.hdr.size = htons (sizeof (struct Wlan_Helper_Control_Message)); | 771 | macmsg.hdr.size = htons (sizeof (struct Wlan_Helper_Control_Message)); |
714 | macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL); | 772 | macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL); |
715 | memcpy (macmsg.mac.mac, mac, sizeof (struct MacAddress)); | 773 | memcpy (macmsg.mac, mac, sizeof (struct MacAddress)); |
716 | memcpy (buffer, &macmsg, sizeof (struct Wlan_Helper_Control_Message)); | 774 | memcpy (buffer, &macmsg, sizeof (struct Wlan_Helper_Control_Message)); |
717 | return sizeof (struct Wlan_Helper_Control_Message); | 775 | return sizeof (struct Wlan_Helper_Control_Message); |
718 | } | 776 | } |
777 | */ | ||
719 | 778 | ||
720 | 779 | //FIXME: doxigen | |
721 | static int | 780 | static int |
722 | hardwaremode (int argc, char *argv[]) | 781 | hardwaremode (int argc, char *argv[]) |
723 | { | 782 | { |
@@ -892,3 +951,79 @@ main (int argc, char *argv[]) | |||
892 | } | 951 | } |
893 | return hardwaremode (argc, argv); | 952 | return hardwaremode (argc, argv); |
894 | } | 953 | } |
954 | |||
955 | /* | ||
956 | * Copyright (c) 2008, Thomas d'Otreppe | ||
957 | * | ||
958 | * Common OSdep stuff | ||
959 | * | ||
960 | * This program is free software; you can redistribute it and/or modify | ||
961 | * it under the terms of the GNU General Public License as published by | ||
962 | * the Free Software Foundation; either version 2 of the License, or | ||
963 | * (at your option) any later version. | ||
964 | * | ||
965 | * This program is distributed in the hope that it will be useful, | ||
966 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
967 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
968 | * GNU General Public License for more details. | ||
969 | * | ||
970 | * You should have received a copy of the GNU General Public License | ||
971 | * along with this program; if not, write to the Free Software | ||
972 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
973 | */ | ||
974 | |||
975 | /** | ||
976 | * Return the frequency in Mhz from a channel number | ||
977 | */ | ||
978 | int | ||
979 | getFrequencyFromChannel (int channel) | ||
980 | { | ||
981 | static int frequencies[] = { | ||
982 | -1, // No channel 0 | ||
983 | 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, | ||
984 | 2472, 2484, | ||
985 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // Nothing from channel 15 to 34 (exclusive) | ||
986 | 5170, 5175, 5180, 5185, 5190, 5195, 5200, 5205, 5210, 5215, 5220, 5225, | ||
987 | 5230, 5235, 5240, 5245, | ||
988 | 5250, 5255, 5260, 5265, 5270, 5275, 5280, 5285, 5290, 5295, 5300, 5305, | ||
989 | 5310, 5315, 5320, 5325, | ||
990 | 5330, 5335, 5340, 5345, 5350, 5355, 5360, 5365, 5370, 5375, 5380, 5385, | ||
991 | 5390, 5395, 5400, 5405, | ||
992 | 5410, 5415, 5420, 5425, 5430, 5435, 5440, 5445, 5450, 5455, 5460, 5465, | ||
993 | 5470, 5475, 5480, 5485, | ||
994 | 5490, 5495, 5500, 5505, 5510, 5515, 5520, 5525, 5530, 5535, 5540, 5545, | ||
995 | 5550, 5555, 5560, 5565, | ||
996 | 5570, 5575, 5580, 5585, 5590, 5595, 5600, 5605, 5610, 5615, 5620, 5625, | ||
997 | 5630, 5635, 5640, 5645, | ||
998 | 5650, 5655, 5660, 5665, 5670, 5675, 5680, 5685, 5690, 5695, 5700, 5705, | ||
999 | 5710, 5715, 5720, 5725, | ||
1000 | 5730, 5735, 5740, 5745, 5750, 5755, 5760, 5765, 5770, 5775, 5780, 5785, | ||
1001 | 5790, 5795, 5800, 5805, | ||
1002 | 5810, 5815, 5820, 5825, 5830, 5835, 5840, 5845, 5850, 5855, 5860, 5865, | ||
1003 | 5870, 5875, 5880, 5885, | ||
1004 | 5890, 5895, 5900, 5905, 5910, 5915, 5920, 5925, 5930, 5935, 5940, 5945, | ||
1005 | 5950, 5955, 5960, 5965, | ||
1006 | 5970, 5975, 5980, 5985, 5990, 5995, 6000, 6005, 6010, 6015, 6020, 6025, | ||
1007 | 6030, 6035, 6040, 6045, | ||
1008 | 6050, 6055, 6060, 6065, 6070, 6075, 6080, 6085, 6090, 6095, 6100 | ||
1009 | }; | ||
1010 | |||
1011 | return (channel > 0 && channel <= 221) ? frequencies[channel] : -1; | ||
1012 | } | ||
1013 | |||
1014 | /** | ||
1015 | * Return the channel from the frequency (in Mhz) | ||
1016 | */ | ||
1017 | int | ||
1018 | getChannelFromFrequency (int frequency) | ||
1019 | { | ||
1020 | if (frequency >= 2412 && frequency <= 2472) | ||
1021 | return (frequency - 2407) / 5; | ||
1022 | else if (frequency == 2484) | ||
1023 | return 14; | ||
1024 | else if (frequency >= 5000 && frequency <= 6100) | ||
1025 | return (frequency - 5000) / 5; | ||
1026 | else | ||
1027 | return -1; | ||
1028 | } | ||
1029 | |||
diff --git a/src/transport/gnunet-transport-wlan-helper.h b/src/transport/gnunet-transport-wlan-helper.h index 0c708f912..8ebba0ce9 100644 --- a/src/transport/gnunet-transport-wlan-helper.h +++ b/src/transport/gnunet-transport-wlan-helper.h | |||
@@ -57,18 +57,4 @@ typedef u32 __le32; | |||
57 | */ | 57 | */ |
58 | #define unlikely(x) (x) | 58 | #define unlikely(x) (x) |
59 | 59 | ||
60 | #define FIFO_FILE1 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_in" | ||
61 | #define FIFO_FILE2 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_out" | ||
62 | #define MAXLINE 4096 | ||
63 | |||
64 | extern int closeprog; | ||
65 | |||
66 | struct sendbuf | ||
67 | { | ||
68 | unsigned int pos; | ||
69 | unsigned int size; | ||
70 | char buf[MAXLINE * 2]; | ||
71 | }; | ||
72 | |||
73 | |||
74 | #endif /* gnunet_wlan_H */ | 60 | #endif /* gnunet_wlan_H */ |
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index d3bd1ef82..f75e507a4 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -24,6 +24,8 @@ | |||
24 | * @author David Brodski | 24 | * @author David Brodski |
25 | */ | 25 | */ |
26 | 26 | ||
27 | //TODO split rx and tx structures for better handling | ||
28 | |||
27 | #include "platform.h" | 29 | #include "platform.h" |
28 | #include "gnunet_hello_lib.h" | 30 | #include "gnunet_hello_lib.h" |
29 | #include "gnunet_protocols.h" | 31 | #include "gnunet_protocols.h" |
@@ -91,7 +93,7 @@ | |||
91 | /** | 93 | /** |
92 | * DEBUG switch | 94 | * DEBUG switch |
93 | */ | 95 | */ |
94 | #define DEBUG_wlan GNUNET_NO | 96 | #define DEBUG_wlan GNUNET_YES |
95 | #define DEBUG_wlan_retransmission GNUNET_NO | 97 | #define DEBUG_wlan_retransmission GNUNET_NO |
96 | #define DEBUG_wlan_ip_udp_packets_on_air GNUNET_NO | 98 | #define DEBUG_wlan_ip_udp_packets_on_air GNUNET_NO |
97 | 99 | ||
@@ -756,7 +758,7 @@ get_macendpoint (struct Plugin *plugin, const struct MacAddress *addr, | |||
756 | } | 758 | } |
757 | 759 | ||
758 | /** | 760 | /** |
759 | * search for a session with the addr and peer id | 761 | * search for a session with the address and peer id |
760 | * | 762 | * |
761 | * @param plugin pointer to the plugin struct | 763 | * @param plugin pointer to the plugin struct |
762 | * @param addr pointer to the mac address of the peer | 764 | * @param addr pointer to the mac address of the peer |
@@ -2281,8 +2283,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
2281 | * Function used for to process the data received from the wlan interface | 2283 | * Function used for to process the data received from the wlan interface |
2282 | * | 2284 | * |
2283 | * @param cls the plugin handle | 2285 | * @param cls the plugin handle |
2284 | * @param session_light FIXME: document | 2286 | * @param session_light pointer to the struct holding known informations |
2285 | * @param hdr hdr of the GNUNET_MessageHeader | 2287 | * @param hdr hdr of the GNUNET_MessageHeader |
2288 | * @param rxinfo pointer to the radiotap informations got with this packet | ||
2286 | */ | 2289 | */ |
2287 | static void | 2290 | static void |
2288 | wlan_data_helper (void *cls, struct Session_light *session_light, | 2291 | wlan_data_helper (void *cls, struct Session_light *session_light, |
@@ -2448,7 +2451,11 @@ wlan_data_helper (void *cls, struct Session_light *session_light, | |||
2448 | 2451 | ||
2449 | } | 2452 | } |
2450 | 2453 | ||
2451 | //TODO DOXIGEN | 2454 | /** |
2455 | * Function to print mac addresses nice * | ||
2456 | * @param pointer to 6 byte with the mac address | ||
2457 | * @return pointer to the chars which hold the print out | ||
2458 | */ | ||
2452 | const char * | 2459 | const char * |
2453 | macprinter (const u_int8_t * mac) | 2460 | macprinter (const u_int8_t * mac) |
2454 | { | 2461 | { |
@@ -2652,6 +2659,12 @@ wlan_process_helper (void *cls, void *client, | |||
2652 | sizeof (struct MacAddress)); | 2659 | sizeof (struct MacAddress)); |
2653 | break; | 2660 | break; |
2654 | default: | 2661 | default: |
2662 | #if DEBUG_wlan | ||
2663 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME, | ||
2664 | "Func wlan_process_helper got unknown message with number %u, size %u\n", | ||
2665 | ntohs (hdr->type), | ||
2666 | ntohs (hdr->size)); | ||
2667 | #endif | ||
2655 | GNUNET_break (0); | 2668 | GNUNET_break (0); |
2656 | return; | 2669 | return; |
2657 | } | 2670 | } |
diff --git a/src/transport/test_plugin_transport_wlan_dummy.c b/src/transport/test_plugin_transport_wlan_dummy.c index 03dedbe4d..077fdac29 100644 --- a/src/transport/test_plugin_transport_wlan_dummy.c +++ b/src/transport/test_plugin_transport_wlan_dummy.c | |||
@@ -47,7 +47,7 @@ | |||
47 | #include "gnunet_util_lib.h" | 47 | #include "gnunet_util_lib.h" |
48 | #include "plugin_transport_wlan.h" | 48 | #include "plugin_transport_wlan.h" |
49 | #include "gnunet_common.h" | 49 | #include "gnunet_common.h" |
50 | #include "gnunet-transport-wlan-helper.h" | 50 | //#include "gnunet-transport-wlan-helper.h" |
51 | #include "gnunet_crypto_lib.h" | 51 | #include "gnunet_crypto_lib.h" |
52 | #include "wlan/loopback_helper.h" | 52 | #include "wlan/loopback_helper.h" |
53 | #include "wlan/helper_common.h" | 53 | #include "wlan/helper_common.h" |
@@ -160,16 +160,16 @@ testmode (int argc, char *argv[]) | |||
160 | //unlink(FIFO_FILE1); | 160 | //unlink(FIFO_FILE1); |
161 | //unlink(FIFO_FILE2); | 161 | //unlink(FIFO_FILE2); |
162 | // FIXME: use mkfifo! | 162 | // FIXME: use mkfifo! |
163 | erg = mknod (FIFO_FILE1, S_IFIFO | 0666, 0); | 163 | erg = mkfifo (FIFO_FILE1, 0666); |
164 | if (0 != erg) | 164 | if (0 != erg) |
165 | { | 165 | { |
166 | fprintf (stderr, "Error at mknode1 \n"); | 166 | fprintf (stderr, "Error at mkfifo1: %s\n", strerror(errno)); |
167 | //exit(1); | 167 | //exit(1); |
168 | } | 168 | } |
169 | erg = mknod (FIFO_FILE2, S_IFIFO | 0666, 0); | 169 | erg = mkfifo (FIFO_FILE2, 0666); |
170 | if (0 != erg) | 170 | if (0 != erg) |
171 | { | 171 | { |
172 | fprintf (stderr, "Error at mknode2 \n"); | 172 | fprintf (stderr, "Error at mkfifo2: %s\n", strerror(errno)); |
173 | //exit(1); | 173 | //exit(1); |
174 | } | 174 | } |
175 | 175 | ||
diff --git a/src/transport/wlan/helper_common.c b/src/transport/wlan/helper_common.c index d4b1204f6..6a7a5da09 100644 --- a/src/transport/wlan/helper_common.c +++ b/src/transport/wlan/helper_common.c | |||
@@ -34,90 +34,15 @@ | |||
34 | * @return number of bytes written | 34 | * @return number of bytes written |
35 | */ | 35 | */ |
36 | int | 36 | int |
37 | send_mac_to_plugin (char *buffer, uint8_t * mac) | 37 | send_mac_to_plugin (char *buffer, struct MacAddress * mac) |
38 | { | 38 | { |
39 | 39 | ||
40 | struct Wlan_Helper_Control_Message macmsg; | 40 | struct Wlan_Helper_Control_Message macmsg; |
41 | 41 | ||
42 | memcpy (macmsg.mac.mac, mac, sizeof (struct MacAddress)); | 42 | memcpy (&macmsg.mac,(char *) mac, sizeof (struct MacAddress)); |
43 | macmsg.hdr.size = htons (sizeof (struct Wlan_Helper_Control_Message)); | 43 | macmsg.hdr.size = htons (sizeof (struct Wlan_Helper_Control_Message)); |
44 | macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL); | 44 | macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL); |
45 | 45 | ||
46 | memcpy (buffer, &macmsg, sizeof (struct Wlan_Helper_Control_Message)); | 46 | memcpy (buffer, &macmsg, sizeof (struct Wlan_Helper_Control_Message)); |
47 | return sizeof (struct Wlan_Helper_Control_Message); | 47 | return sizeof (struct Wlan_Helper_Control_Message); |
48 | } | 48 | } |
49 | |||
50 | /* | ||
51 | * Copyright (c) 2008, Thomas d'Otreppe | ||
52 | * | ||
53 | * Common OSdep stuff | ||
54 | * | ||
55 | * This program is free software; you can redistribute it and/or modify | ||
56 | * it under the terms of the GNU General Public License as published by | ||
57 | * the Free Software Foundation; either version 2 of the License, or | ||
58 | * (at your option) any later version. | ||
59 | * | ||
60 | * This program is distributed in the hope that it will be useful, | ||
61 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
62 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
63 | * GNU General Public License for more details. | ||
64 | * | ||
65 | * You should have received a copy of the GNU General Public License | ||
66 | * along with this program; if not, write to the Free Software | ||
67 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
68 | */ | ||
69 | |||
70 | /** | ||
71 | * Return the frequency in Mhz from a channel number | ||
72 | */ | ||
73 | int | ||
74 | getFrequencyFromChannel (int channel) | ||
75 | { | ||
76 | static int frequencies[] = { | ||
77 | -1, // No channel 0 | ||
78 | 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, | ||
79 | 2472, 2484, | ||
80 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // Nothing from channel 15 to 34 (exclusive) | ||
81 | 5170, 5175, 5180, 5185, 5190, 5195, 5200, 5205, 5210, 5215, 5220, 5225, | ||
82 | 5230, 5235, 5240, 5245, | ||
83 | 5250, 5255, 5260, 5265, 5270, 5275, 5280, 5285, 5290, 5295, 5300, 5305, | ||
84 | 5310, 5315, 5320, 5325, | ||
85 | 5330, 5335, 5340, 5345, 5350, 5355, 5360, 5365, 5370, 5375, 5380, 5385, | ||
86 | 5390, 5395, 5400, 5405, | ||
87 | 5410, 5415, 5420, 5425, 5430, 5435, 5440, 5445, 5450, 5455, 5460, 5465, | ||
88 | 5470, 5475, 5480, 5485, | ||
89 | 5490, 5495, 5500, 5505, 5510, 5515, 5520, 5525, 5530, 5535, 5540, 5545, | ||
90 | 5550, 5555, 5560, 5565, | ||
91 | 5570, 5575, 5580, 5585, 5590, 5595, 5600, 5605, 5610, 5615, 5620, 5625, | ||
92 | 5630, 5635, 5640, 5645, | ||
93 | 5650, 5655, 5660, 5665, 5670, 5675, 5680, 5685, 5690, 5695, 5700, 5705, | ||
94 | 5710, 5715, 5720, 5725, | ||
95 | 5730, 5735, 5740, 5745, 5750, 5755, 5760, 5765, 5770, 5775, 5780, 5785, | ||
96 | 5790, 5795, 5800, 5805, | ||
97 | 5810, 5815, 5820, 5825, 5830, 5835, 5840, 5845, 5850, 5855, 5860, 5865, | ||
98 | 5870, 5875, 5880, 5885, | ||
99 | 5890, 5895, 5900, 5905, 5910, 5915, 5920, 5925, 5930, 5935, 5940, 5945, | ||
100 | 5950, 5955, 5960, 5965, | ||
101 | 5970, 5975, 5980, 5985, 5990, 5995, 6000, 6005, 6010, 6015, 6020, 6025, | ||
102 | 6030, 6035, 6040, 6045, | ||
103 | 6050, 6055, 6060, 6065, 6070, 6075, 6080, 6085, 6090, 6095, 6100 | ||
104 | }; | ||
105 | |||
106 | return (channel > 0 && channel <= 221) ? frequencies[channel] : -1; | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * Return the channel from the frequency (in Mhz) | ||
111 | */ | ||
112 | int | ||
113 | getChannelFromFrequency (int frequency) | ||
114 | { | ||
115 | if (frequency >= 2412 && frequency <= 2472) | ||
116 | return (frequency - 2407) / 5; | ||
117 | else if (frequency == 2484) | ||
118 | return 14; | ||
119 | else if (frequency >= 5000 && frequency <= 6100) | ||
120 | return (frequency - 5000) / 5; | ||
121 | else | ||
122 | return -1; | ||
123 | } | ||
diff --git a/src/transport/wlan/helper_common.h b/src/transport/wlan/helper_common.h index 3c33887d1..9d53176c6 100644 --- a/src/transport/wlan/helper_common.h +++ b/src/transport/wlan/helper_common.h | |||
@@ -9,10 +9,16 @@ | |||
9 | #define HELPER_COMMON_H_ | 9 | #define HELPER_COMMON_H_ |
10 | 10 | ||
11 | int | 11 | int |
12 | getFrequencyFromChannel (int channel); | ||
13 | int | ||
14 | getChannelFromFrequency (int frequency); | ||
15 | int | ||
16 | send_mac_to_plugin (char *buffer, uint8_t * mac); | 12 | send_mac_to_plugin (char *buffer, uint8_t * mac); |
17 | 13 | ||
14 | |||
15 | #define MAXLINE 4096 | ||
16 | |||
17 | struct sendbuf | ||
18 | { | ||
19 | unsigned int pos; | ||
20 | unsigned int size; | ||
21 | char buf[MAXLINE * 2]; | ||
22 | }; | ||
23 | |||
18 | #endif /* HELPER_COMMON_H_ */ | 24 | #endif /* HELPER_COMMON_H_ */ |
diff --git a/src/transport/wlan/loopback_helper.h b/src/transport/wlan/loopback_helper.h index 81cc66f22..5da3d834e 100644 --- a/src/transport/wlan/loopback_helper.h +++ b/src/transport/wlan/loopback_helper.h | |||
@@ -17,4 +17,10 @@ | |||
17 | int | 17 | int |
18 | testmode (int argc, char *argv[]); | 18 | testmode (int argc, char *argv[]); |
19 | 19 | ||
20 | |||
21 | #define FIFO_FILE1 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_in" | ||
22 | #define FIFO_FILE2 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_out" | ||
23 | |||
24 | extern int closeprog; | ||
25 | |||
20 | #endif /* LOOPBACK_HELPER_H_ */ | 26 | #endif /* LOOPBACK_HELPER_H_ */ |