wificurse

wifi jamming tool
git clone git://git.2f30.org/wificurse
Log | Files | Refs | README | LICENSE

channelset.h (1598B)


      1 /*
      2     wificurse - WiFi Jamming tool
      3     Copyright (C) 2012  oblique
      4 
      5     This program is free software: you can redistribute it and/or modify
      6     it under the terms of the GNU General Public License as published by
      7     the Free Software Foundation, either version 3 of the License, or
      8     (at your option) any later version.
      9 
     10     This program is distributed in the hope that it will be useful,
     11     but WITHOUT ANY WARRANTY; without even the implied warranty of
     12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13     GNU General Public License for more details.
     14 
     15     You should have received a copy of the GNU General Public License
     16     along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 */
     18 
     19 #ifndef CHANNELSET_H
     20 #define CHANNELSET_H
     21 
     22 #include <stdint.h>
     23 
     24 #define CHANNEL_MAX 255
     25 typedef uint32_t channelset_t[8];
     26 
     27 static inline void channel_zero(channelset_t *cs) {
     28 	uint32_t *c = (uint32_t*)cs;
     29 	c[0] = c[1] = c[2] = c[3] = 0;
     30 	c[4] = c[5] = c[6] = c[7] = 0;
     31 }
     32 
     33 static inline void channel_set(channelset_t *cs, uint8_t chan) {
     34 	uint32_t *c = (uint32_t*)cs;
     35 	c[chan/32] |= 1 << (chan % 32);
     36 }
     37 
     38 static inline void channel_unset(channelset_t *cs, uint8_t chan) {
     39 	uint32_t *c = (uint32_t*)cs;
     40 	c[chan/32] &= ~(1 << (chan % 32));
     41 }
     42 
     43 static inline int channel_isset(channelset_t *cs, uint8_t chan) {
     44 	uint32_t *c = (uint32_t*)cs;
     45 	return !!(c[chan/32] & (1 << (chan % 32)));
     46 }
     47 
     48 static inline void channel_copy(channelset_t *dest, channelset_t *src) {
     49 	uint32_t i, *dc, *sc;
     50 	dc = (uint32_t*)dest;
     51 	sc = (uint32_t*)src;
     52 	for (i=0; i<8; i++)
     53 		dc[i] = sc[i];
     54 }
     55 
     56 #endif