|
25 | 25 | #include "6LoWPAN/ws/ws_ie_lib.h"
|
26 | 26 | #include "6LoWPAN/ws/ws_common_defines.h"
|
27 | 27 | #include "common_functions_stub.h"
|
| 28 | +#include "mac_ie_lib_stub.h" |
28 | 29 |
|
29 | 30 | bool test_ws_ie_lib_header()
|
30 | 31 | {
|
@@ -117,3 +118,275 @@ bool test_ws_ie_lib_payload()
|
117 | 118 |
|
118 | 119 | return true;
|
119 | 120 | }
|
| 121 | + |
| 122 | +bool test_ws_wp_nested_hopping_schedule_length() |
| 123 | +{ |
| 124 | + uint16_t length; |
| 125 | + ws_hopping_schedule_t shedule; |
| 126 | + |
| 127 | + memset (&shedule, 0, sizeof(ws_hopping_schedule_t)); |
| 128 | + length = ws_wp_nested_hopping_schedule_length(&shedule, true); |
| 129 | + if (length != 4 + 2 +2) |
| 130 | + { |
| 131 | + return false; |
| 132 | + } |
| 133 | + |
| 134 | + shedule.channel_plan = 1; |
| 135 | + shedule.channel_function = 1; |
| 136 | + length = ws_wp_nested_hopping_schedule_length(&shedule, true); |
| 137 | + if (length != 4 + 6) |
| 138 | + { |
| 139 | + return false; |
| 140 | + } |
| 141 | + shedule.channel_plan = 2; |
| 142 | + shedule.channel_function = 3; |
| 143 | + |
| 144 | + length = ws_wp_nested_hopping_schedule_length(&shedule, true); |
| 145 | + if (length != 6) |
| 146 | + { |
| 147 | + return false; |
| 148 | + } |
| 149 | + |
| 150 | + length = ws_wp_nested_hopping_schedule_length(&shedule, false); |
| 151 | + if (length != 12) |
| 152 | + { |
| 153 | + return false; |
| 154 | + } |
| 155 | + return true; |
| 156 | +} |
| 157 | + |
| 158 | +bool test_ws_wp_nested_hopping_schedule_write() |
| 159 | +{ |
| 160 | + uint8_t temp_buf[20]; |
| 161 | + uint8_t *ptr; |
| 162 | + ws_hopping_schedule_t shedule; |
| 163 | + memset (&shedule, 0, sizeof(ws_hopping_schedule_t)); |
| 164 | + |
| 165 | + ptr = ws_wp_nested_hopping_schedule_write(temp_buf, &shedule, true); |
| 166 | + if (ptr != temp_buf + 8 + 2) { |
| 167 | + return false; |
| 168 | + } |
| 169 | + |
| 170 | + shedule.channel_plan = 1; |
| 171 | + shedule.channel_function = 1; |
| 172 | + ptr = ws_wp_nested_hopping_schedule_write(temp_buf, &shedule, true); |
| 173 | + if (ptr != temp_buf + 10 + 2) { |
| 174 | + return false; |
| 175 | + } |
| 176 | + |
| 177 | + shedule.channel_plan = 2; |
| 178 | + shedule.channel_function = 3; |
| 179 | + ptr = ws_wp_nested_hopping_schedule_write(temp_buf, &shedule, false); |
| 180 | + if (ptr != temp_buf + 10 + 2 + 2) { |
| 181 | + return false; |
| 182 | + } |
| 183 | + |
| 184 | + return true; |
| 185 | +} |
| 186 | + |
| 187 | +bool test_ws_wh_utt_read() |
| 188 | +{ |
| 189 | + uint8_t temp_buf[20]; |
| 190 | + ws_utt_ie_t utt_ie; |
| 191 | + mac_ie_lib_stub_def.value_uint8 = 0; |
| 192 | + if (ws_wh_utt_read(temp_buf, 8, &utt_ie) ) { |
| 193 | + return false; |
| 194 | + } |
| 195 | + |
| 196 | + mac_ie_lib_stub_def.value_uint8 = 4; |
| 197 | + return ws_wh_utt_read(temp_buf, 8, &utt_ie); |
| 198 | +} |
| 199 | + |
| 200 | +bool test_ws_wh_bt_read() |
| 201 | +{ |
| 202 | + uint8_t temp_buf[20]; |
| 203 | + ws_bt_ie_t bt_ie; |
| 204 | + mac_ie_lib_stub_def.value_uint8 = 0; |
| 205 | + if (ws_wh_bt_read(temp_buf, 8, &bt_ie) ) { |
| 206 | + return false; |
| 207 | + } |
| 208 | + |
| 209 | + mac_ie_lib_stub_def.value_uint8 = 5; |
| 210 | + return ws_wh_bt_read(temp_buf, 8, &bt_ie); |
| 211 | +} |
| 212 | + |
| 213 | +bool test_ws_wp_nested_us_read() |
| 214 | +{ |
| 215 | + |
| 216 | + ws_us_ie_t ws_us_ie; |
| 217 | + uint8_t temp_buf[20]; |
| 218 | + mac_ie_lib_stub_def.value_uint16 = 3; |
| 219 | + temp_buf[3] = 0; |
| 220 | + if (ws_wp_nested_us_read(temp_buf, 40, &ws_us_ie) ){ |
| 221 | + return false; |
| 222 | + } |
| 223 | + |
| 224 | + mac_ie_lib_stub_def.value_uint16 = 4; |
| 225 | + if (ws_wp_nested_us_read(temp_buf, 40, &ws_us_ie) ){ |
| 226 | + return false; |
| 227 | + } |
| 228 | + |
| 229 | + mac_ie_lib_stub_def.value_uint16 = 7; |
| 230 | + if (ws_wp_nested_us_read(temp_buf, 40, &ws_us_ie) ){ |
| 231 | + return false; |
| 232 | + } |
| 233 | + |
| 234 | + mac_ie_lib_stub_def.value_uint16 = 8; |
| 235 | + if (!ws_wp_nested_us_read(temp_buf, 40, &ws_us_ie)) { |
| 236 | + return false; |
| 237 | + } |
| 238 | + temp_buf[3] = 1; |
| 239 | + |
| 240 | + if (ws_wp_nested_us_read(temp_buf, 40, &ws_us_ie)) { |
| 241 | + return false; |
| 242 | + } |
| 243 | + mac_ie_lib_stub_def.value_uint16 = 12; |
| 244 | + if (!ws_wp_nested_us_read(temp_buf, 40, &ws_us_ie)) { |
| 245 | + return false; |
| 246 | + } |
| 247 | + temp_buf[3] = 2; |
| 248 | + if (ws_wp_nested_us_read(temp_buf, 40, &ws_us_ie)) { |
| 249 | + return false; |
| 250 | + } |
| 251 | + |
| 252 | + temp_buf[3] = 1 << 3; |
| 253 | + mac_ie_lib_stub_def.value_uint16 = 6; |
| 254 | + if (!ws_wp_nested_us_read(temp_buf, 40, &ws_us_ie)) { |
| 255 | + return false; |
| 256 | + } |
| 257 | + |
| 258 | + temp_buf[3] = 3 << 3; |
| 259 | + mac_ie_lib_stub_def.value_uint16 = 7; |
| 260 | + temp_buf[6] = 2; |
| 261 | + if (ws_wp_nested_us_read(temp_buf, 40, &ws_us_ie)) { |
| 262 | + return false; |
| 263 | + } |
| 264 | + mac_ie_lib_stub_def.value_uint16 = 9; |
| 265 | + if (!ws_wp_nested_us_read(temp_buf, 40, &ws_us_ie)) { |
| 266 | + return false; |
| 267 | + } |
| 268 | + |
| 269 | + temp_buf[3] = 4 << 3; |
| 270 | + if (ws_wp_nested_us_read(temp_buf, 40, &ws_us_ie)) { |
| 271 | + return false; |
| 272 | + } |
| 273 | + |
| 274 | + return true; |
| 275 | + |
| 276 | +} |
| 277 | + |
| 278 | + |
| 279 | +bool test_ws_wp_nested_bs_read() |
| 280 | +{ |
| 281 | + |
| 282 | + ws_bs_ie_t ws_bs_ie; |
| 283 | + uint8_t temp_buf[20]; |
| 284 | + mac_ie_lib_stub_def.value_uint16 = 9; |
| 285 | + temp_buf[9] = 0; |
| 286 | + if (ws_wp_nested_bs_read(temp_buf, 40, &ws_bs_ie) ){ |
| 287 | + return false; |
| 288 | + } |
| 289 | + |
| 290 | + mac_ie_lib_stub_def.value_uint16 = 10; |
| 291 | + if (ws_wp_nested_bs_read(temp_buf, 40, &ws_bs_ie) ){ |
| 292 | + return false; |
| 293 | + } |
| 294 | + |
| 295 | + mac_ie_lib_stub_def.value_uint16 = 13; |
| 296 | + if (ws_wp_nested_bs_read(temp_buf, 40, &ws_bs_ie) ){ |
| 297 | + return false; |
| 298 | + } |
| 299 | + |
| 300 | + mac_ie_lib_stub_def.value_uint16 = 14; |
| 301 | + if (!ws_wp_nested_bs_read(temp_buf, 40, &ws_bs_ie)) { |
| 302 | + return false; |
| 303 | + } |
| 304 | + |
| 305 | + temp_buf[9] = 1; |
| 306 | + if (ws_wp_nested_bs_read(temp_buf, 40, &ws_bs_ie)) { |
| 307 | + return false; |
| 308 | + } |
| 309 | + |
| 310 | + mac_ie_lib_stub_def.value_uint16 = 18; |
| 311 | + if (!ws_wp_nested_bs_read(temp_buf, 40, &ws_bs_ie)) { |
| 312 | + return false; |
| 313 | + } |
| 314 | + |
| 315 | + temp_buf[9] = 2; |
| 316 | + if (ws_wp_nested_bs_read(temp_buf, 40, &ws_bs_ie)) { |
| 317 | + return false; |
| 318 | + } |
| 319 | + |
| 320 | + temp_buf[9] = 4 << 3; |
| 321 | + if (ws_wp_nested_bs_read(temp_buf, 40, &ws_bs_ie)) { |
| 322 | + return false; |
| 323 | + } |
| 324 | + |
| 325 | + temp_buf[9] = 1 << 3; |
| 326 | + mac_ie_lib_stub_def.value_uint16 = 12; |
| 327 | + if (!ws_wp_nested_bs_read(temp_buf, 40, &ws_bs_ie)) { |
| 328 | + return false; |
| 329 | + } |
| 330 | + |
| 331 | + temp_buf[9] = 3 << 3; |
| 332 | + temp_buf[12] = 2; |
| 333 | + mac_ie_lib_stub_def.value_uint16 = 13; |
| 334 | + if (ws_wp_nested_bs_read(temp_buf, 40, &ws_bs_ie)) { |
| 335 | + return false; |
| 336 | + } |
| 337 | + |
| 338 | + mac_ie_lib_stub_def.value_uint16 = 15; |
| 339 | + if (!ws_wp_nested_bs_read(temp_buf, 40, &ws_bs_ie)) { |
| 340 | + return false; |
| 341 | + } |
| 342 | + |
| 343 | + return true; |
| 344 | + |
| 345 | +} |
| 346 | + |
| 347 | +bool test_ws_wp_nested_pan_read() |
| 348 | +{ |
| 349 | + ws_pan_information_t ws_pan_ie; |
| 350 | + uint8_t temp_buf[20]; |
| 351 | + mac_ie_lib_stub_def.value_uint16 = 4; |
| 352 | + if (ws_wp_nested_pan_read(temp_buf, 20, &ws_pan_ie)) { |
| 353 | + return false; |
| 354 | + } |
| 355 | + mac_ie_lib_stub_def.value_uint16 = 5; |
| 356 | + |
| 357 | + return ws_wp_nested_pan_read(temp_buf, 20, &ws_pan_ie); |
| 358 | +} |
| 359 | + |
| 360 | +bool test_ws_wp_nested_pan_version_read() |
| 361 | +{ |
| 362 | + uint16_t ws_pan_version; |
| 363 | + uint8_t temp_buf[20]; |
| 364 | + mac_ie_lib_stub_def.value_uint16 = 4; |
| 365 | + if (ws_wp_nested_pan_version_read(temp_buf, 20, &ws_pan_version)) { |
| 366 | + return false; |
| 367 | + } |
| 368 | + |
| 369 | + mac_ie_lib_stub_def.value_uint16 = 2; |
| 370 | + if (!ws_wp_nested_pan_version_read(temp_buf, 20, &ws_pan_version)) { |
| 371 | + return false; |
| 372 | + } |
| 373 | + |
| 374 | + return true; |
| 375 | +} |
| 376 | + |
| 377 | +bool test_ws_wp_nested_gtkhash_read() |
| 378 | +{ |
| 379 | + uint8_t temp_buf[40]; |
| 380 | + mac_ie_lib_stub_def.value_uint16 = 4; |
| 381 | + if (ws_wp_nested_gtkhash_read(temp_buf, 40)) { |
| 382 | + return false; |
| 383 | + } |
| 384 | + |
| 385 | + mac_ie_lib_stub_def.value_uint16 = 32; |
| 386 | + if (!ws_wp_nested_gtkhash_read(temp_buf, 20)) { |
| 387 | + return false; |
| 388 | + } |
| 389 | + |
| 390 | + return true; |
| 391 | +} |
| 392 | + |
0 commit comments