#include #include #include #define CCK 1 #define OFDM 2 struct ieee80211_rate_table { int rateCount; /* NB: for proper padding */ uint8_t rateCodeToIndex[256]; /* back mapping */ struct { uint8_t phy; /* CCK/OFDM/TURBO */ uint32_t rateKbps; /* transfer rate in kbs */ uint8_t shortPreamble; /* mask for enabling short * preamble in CCK rate code */ uint8_t dot11Rate; /* value for supported rates * info element of MLME */ uint8_t controlRate; /* index of next lower basic * rate; used for dur. calcs */ uint16_t lpAckDuration; /* long preamble ACK dur. */ uint16_t spAckDuration; /* short preamble ACK dur. */ } info[32]; }; static struct ieee80211_rate_table ieee80211_11g_table = { #if 0 12, /* number of rates */ #else 3, #endif { 0 }, { /* short ctrl */ /* Preamble dot11Rate Rate */ #if 0 /* 1 Mb */ { CCK, 1000, 0x00, (0x80| 2), 0 }, #endif /* 2 Mb */ { CCK, 2000, 0x04, (0x80| 4), 1 }, /* 5.5 Mb */ { CCK, 5500, 0x04, (0x80|11), 2 }, /* 11 Mb */ { CCK, 11000, 0x04, (0x80|22), 3 }, #if 0 /* 6 Mb */ { OFDM, 6000, 0x00, 12, 4 }, /* 9 Mb */ { OFDM, 9000, 0x00, 18, 4 }, /* 12 Mb */ { OFDM, 12000, 0x00, 24, 6 }, /* 18 Mb */ { OFDM, 18000, 0x00, 36, 6 }, /* 24 Mb */ { OFDM, 24000, 0x00, 48, 8 }, /* 36 Mb */ { OFDM, 36000, 0x00, 72, 8 }, /* 48 Mb */ { OFDM, 48000, 0x00, 96, 8 }, /* 54 Mb */ { OFDM, 54000, 0x00, 108, 8 } #endif }, }; int main(void) { #define N(a) (sizeof(a)/sizeof(a[0])) #define WLAN_CTRL_FRAME_SIZE (2+2+6+4) /* ACK+FCS */ struct ieee80211_rate_table *rt = &ieee80211_11g_table; int i; for (i = 0; i < N(rt->rateCodeToIndex); i++) rt->rateCodeToIndex[i] = (uint8_t) -1; for (i = 0; i < rt->rateCount; i++) { uint8_t code = rt->info[i].dot11Rate; #if 0 if (code >= 256) { fprintf(stderr, "error code %#x\n", code); exit(1); } if ((code | rt->info[i].shortPreamble) >= 256) { fprintf(stderr, "error code %#x\n", code | rt->info[i].shortPreamble); exit(1); } #endif rt->rateCodeToIndex[code] = i; rt->rateCodeToIndex[code | rt->info[i].shortPreamble] = i; if (code & 0x80) { /* * Map w/o basic rate bit too. */ code &= 0x7f; rt->rateCodeToIndex[code] = i; rt->rateCodeToIndex[code | rt->info[i].shortPreamble] = i; } } #undef WLAN_CTRL_FRAME_SIZE #undef N for (i = 0; i < 256; ++i) { if (i != 0 && i % 16 == 0) printf("\n"); printf("%02x ", rt->rateCodeToIndex[i]); } printf("\n"); exit(0); }