nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /*************************************************************************** |
2 | * * |
||
3 | * ########### ########### ########## ########## * |
||
4 | * ############ ############ ############ ############ * |
||
5 | * ## ## ## ## ## ## ## * |
||
6 | * ## ## ## ## ## ## ## * |
||
7 | * ########### #### ###### ## ## ## ## ###### * |
||
8 | * ########### #### # ## ## ## ## # # * |
||
9 | * ## ## ###### ## ## ## ## # # * |
||
10 | * ## ## # ## ## ## ## # # * |
||
11 | * ############ ##### ###### ## ## ## ##### ###### * |
||
12 | * ########### ########### ## ## ## ########## * |
||
13 | * * |
||
14 | * S E C U R E M O B I L E N E T W O R K I N G * |
||
15 | * * |
||
16 | * This file is part of NexMon. * |
||
17 | * * |
||
18 | * Copyright (c) 2016 NexMon Team * |
||
19 | * * |
||
20 | * NexMon is free software: you can redistribute it and/or modify * |
||
21 | * it under the terms of the GNU General Public License as published by * |
||
22 | * the Free Software Foundation, either version 3 of the License, or * |
||
23 | * (at your option) any later version. * |
||
24 | * * |
||
25 | * NexMon is distributed in the hope that it will be useful, * |
||
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
||
28 | * GNU General Public License for more details. * |
||
29 | * * |
||
30 | * You should have received a copy of the GNU General Public License * |
||
31 | * along with NexMon. If not, see <http://www.gnu.org/licenses/>. * |
||
32 | * * |
||
33 | **************************************************************************/ |
||
34 | |||
35 | #pragma NEXMON targetregion "patch" |
||
36 | |||
37 | #include <firmware_version.h> // definition of firmware version macros |
||
38 | #include <debug.h> // contains macros to access the debug hardware |
||
39 | #include <wrapper.h> // wrapper definitions for functions that already exist in the firmware |
||
40 | #include <structs.h> // structures that are used by the code in the firmware |
||
41 | #include <helper.h> // useful helper functions |
||
42 | #include <patcher.h> // macros used to craete patches such as BLPatch, BPatch, ... |
||
43 | #include <rates.h> // rates used to build the ratespec for frame injection |
||
44 | #include <ieee80211_radiotap.h> // radiotap header related |
||
45 | #include <vendor_radiotap.h> // vendor specific radiotap extensions |
||
46 | |||
47 | char |
||
48 | sendframe(struct wlc_info *wlc, struct sk_buff *p, unsigned int fifo, unsigned int rate); |
||
49 | |||
50 | inline uint32_t |
||
51 | get_unaligned_le32(void *p) { |
||
52 | return ((uint8 *) p)[0] | ((uint8 *) p)[1] << 8 | ((uint8 *) p)[2] << 16 | ((uint8 *) p)[3] << 24; |
||
53 | } |
||
54 | |||
55 | void * |
||
56 | inject_frame(struct wlc_info *wlc, struct sk_buff *p) |
||
57 | { |
||
58 | int rtap_len = 0; |
||
59 | int data_rate = 0; |
||
60 | unsigned char use_ratespec = 0; |
||
61 | //int txdelay = 0; |
||
62 | //int txrepetitions = 0; |
||
63 | //int txperiodicity = 0; |
||
64 | |||
65 | // Radiotap parsing: |
||
66 | struct ieee80211_radiotap_iterator iterator; |
||
67 | struct ieee80211_radiotap_header *rtap_header; |
||
68 | |||
69 | // parse radiotap header |
||
70 | rtap_len = *((char *)(p->data + 2)); |
||
71 | rtap_header = (struct ieee80211_radiotap_header *) p->data; |
||
72 | |||
73 | int ret = ieee80211_radiotap_iterator_init(&iterator, rtap_header, rtap_len, &rtap_vendor_namespaces); |
||
74 | |||
75 | if(ret) { |
||
76 | pkt_buf_free_skb(wlc->osh, p, 0); |
||
77 | printf("rtap_init error\n"); |
||
78 | return 0; |
||
79 | } |
||
80 | |||
81 | while(!ret) { |
||
82 | ret = ieee80211_radiotap_iterator_next(&iterator); |
||
83 | |||
84 | if(ret) { |
||
85 | continue; |
||
86 | } |
||
87 | |||
88 | if (iterator.current_namespace == &rtap_vendor_namespaces.ns[0]) { |
||
89 | switch(iterator.this_arg_index) { |
||
90 | case RADIOTAP_NEX_TXDELAY: |
||
91 | //txdelay = get_unaligned_le32(iterator.this_arg); |
||
92 | break; |
||
93 | |||
94 | case RADIOTAP_NEX_TXREPETITIONS: |
||
95 | //txrepetitions = get_unaligned_le32(iterator.this_arg); |
||
96 | //txperiodicity = get_unaligned_le32(iterator.this_arg + 4); |
||
97 | break; |
||
98 | |||
99 | case RADIOTAP_NEX_RATESPEC: |
||
100 | data_rate = get_unaligned_le32(iterator.this_arg); |
||
101 | use_ratespec = 1; // this will override the rate of the regular radiotap header |
||
102 | break; |
||
103 | |||
104 | default: |
||
105 | printf("unknows vendor field %d\n", iterator.this_arg_index); |
||
106 | } |
||
107 | |||
108 | } else if (iterator.current_namespace == &radiotap_ns) { |
||
109 | switch(iterator.this_arg_index) { |
||
110 | case IEEE80211_RADIOTAP_RATE: |
||
111 | if (!use_ratespec) { |
||
112 | data_rate = (*iterator.this_arg); |
||
113 | } |
||
114 | break; |
||
115 | |||
116 | case IEEE80211_RADIOTAP_CHANNEL: |
||
117 | //printf("Channel (freq): %d\n", iterator.this_arg[0] | (iterator.this_arg[1] << 8) ); |
||
118 | break; |
||
119 | |||
120 | default: |
||
121 | //printf("default: %d\n", iterator.this_arg_index); |
||
122 | break; |
||
123 | } |
||
124 | } |
||
125 | } |
||
126 | |||
127 | // remove radiotap header |
||
128 | skb_pull(p, rtap_len); |
||
129 | |||
130 | sendframe(wlc, p, 1, data_rate); |
||
131 | |||
132 | return 0; |
||
133 | } |