An 802.11 Frame Generation and Parsing Library in C

Overview

libwifi

802.11 Parsing / Generation library

Build Status OS Architecture
X86_64 Linux x86_64

What is this?

libwifi is a C library with a permissive license for generating and parsing a wide variety of 802.11 wireless frames (see the Feature Checklist) on Linux with a few lines of straight forward code (see the Examples section below).

It is written with a simple-to-use approach while also exposing features that allow more advanced use, with clean and readable code being a priority. Other goals of the library include cross-architecture support, clean compilation without warnings and strict error checking.

The library is fully documented with code comments in both the headers files and the code files, and also has doxygen HTML documentation in docs/html.

Building and Installing

Linux

$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install

Examples

Some examples are available in the examples/ directory, which show the general flow of how libwifi is used to generate and parse different types of 802.11 frame.

Running Tests

$ cd test/
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo iw <interface> set type monitor && sudo ip link set dev <interface> up
$ ./test-program
Comments
  • Fix radiotap padding

    Fix radiotap padding

    According to the section "Alignment in Radiotap" on the radiotap website, the radiotap header fields must be padded. 8-bit fields must be 8-bit aligned, 16-bit must be 16-bit aligned, etc. In the current implementation, libwifi_create_radiotap with RATE, CHANNEL, and DBM_TX_POWER fields will be generated incorrectly, due to misalignment from the RATE field. This PR adds the appropriate padding.

    opened by jefflongo 3
  • 802.1X_FT auth key suite ends up being parsed (?) as 802.1X

    802.1X_FT auth key suite ends up being parsed (?) as 802.1X

    I am not sure of what I am seeing here, but it seems to me that, I don't know why, beacon frame with an Auth key Suites of 802.1X_FT (3) ends up being shown as 802.1X.

    I found this because of my tests, but using the examples/parse_beacon/parse_beacon.c on the same .pcap file gives the same problem:

     $ ./parse_beacon/parse_beacon --file beacons.pcap
    [...]
    ESSID: DEMOWIFI
    BSSID: 22:18:0a:6f:5a:ea
    Receiver: ff:ff:ff:ff:ff:ff
    Transmitter: 22:18:0a:6f:5a:ea
    Channel: 11
    WPS: No
    Encryption: WPA2, WPA
    	Group Ciphers: TKIP
    	Pairwise Ciphers: TKIP, CCMP128
    	Auth Key Suites: 802.1X
    Tagged Parameters:
    [...]
    

    Shouldn't there be a 802.1X_FT in Auth Key Suites line ?

    beacons.pcap.gz

    opened by solsticedhiver 3
  • Examples missing Makefiles

    Examples missing Makefiles

    The documentation states that you should be able to cd into the various example directories and run make in their readmes but there are no Makefiles in them.

    opened by steev 1
  • Add support for 6GHz and initial extension tag parsing

    Add support for 6GHz and initial extension tag parsing

    This PR adds support for 6GHz by looking at the Radiotap header of a supplied frame.

    From commit 7c2b373b:

    Radiotap information is now stored in the libwifi_frame struct, and will be kept automatically in libwifi_frame.radiotap_info for the lifecycle of said frame, if it is present.

    A new flag has been added for the frame for use with libwifi_frame.flags to detect if the radiotap info is present: LIBWIFI_FLAGS_RADIOTAP_PRESENT.

    The frame parser will now automatically calculate the band and center channel from radiotap data, and will store them in libwifi_radiotap_info.channel.center and libwifi_radiotap_info.channel.band.

    Four new flags have been added for use with the new radiotap band field:

    • LIBWIFI_RADIOTAP_BAND_2GHZ
    • LIBWIFI_RADIOTAP_BAND_5GHZ
    • LIBWIFI_RADIOTAP_BAND_6GHZ
    • LIBWIFI_RADIOTAP_BAND_900MHZ

    These can be used with a binary AND: if (rtap.channel.band & LIBWIFI_RADIOTAP_BAND_6GHZ) { }

    opened by foxtrot 0
  • Tagged Parameter Improvements

    Tagged Parameter Improvements

    This PR adds

    • A bug fix for parsing tagged parameters with a length of zero
    • A function to check if a tagged parameter is present via tag number (libwifi_check_tag(...))
    • A function to get the tagged parameter name via a tag number (libwifi_get_tag_name(...))
    opened by foxtrot 0
  • test: Add ctests for parse and generate functions.

    test: Add ctests for parse and generate functions.

    This commit also enforces error code checking on functions inside of the generation functions, such as for libwifi_quick_add_tag.

    • [X] Generation Tests
    • [ ] Parser Tests
    • [ ] Update comment doc for new generation function returns
    opened by foxtrot 0
  • Minor compilation error on armv6 (32 bits)

    Minor compilation error on armv6 (32 bits)

    In a very specific build setup (using meson+ninja and gcc only), on armv6l, I came across that build error:

    [112/132] Compiling C object subprojects/libwifi-0.0.6/examples/parse_eapol.p/parse_eapol_parse_eapol.c.o
    FAILED: subprojects/libwifi-0.0.6/examples/parse_eapol.p/parse_eapol_parse_eapol.c.o 
    cc -Isubprojects/libwifi-0.0.6/examples/parse_eapol.p -Isubprojects/libwifi-0.0.6/examples -I../subprojects/libwifi-0.0.6/examples -I../subprojects/libwifi-0.0.6/src -I/usr/local/include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -Wall -Werror -O3 -MD -MQ subprojects/libwifi-0.0.6/examples/parse_eapol.p/parse_eapol_parse_eapol.c.o -MF subprojects/libwifi-0.0.6/examples/parse_eapol.p/parse_eapol_parse_eapol.c.o.d -o subprojects/libwifi-0.0.6/examples/parse_eapol.p/parse_eapol_parse_eapol.c.o -c ../subprojects/libwifi-0.0.6/examples/parse_eapol/parse_eapol.c
    ../subprojects/libwifi-0.0.6/examples/parse_eapol/parse_eapol.c: In function ‘handle_pkt’:
    ../subprojects/libwifi-0.0.6/examples/parse_eapol/parse_eapol.c:41:56: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
       41 |             printf("EAPOL: Key Info: Replay Counter: %lu\n", data.key_info.replay_counter);
          |                                                      ~~^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |                                                        |                  |
          |                                                        long unsigned int  uint64_t {aka long long unsigned int}
          |                                                      %llu
    cc1: all warnings being treated as errors
    [113/132] Compiling C object subprojects/libwifi-0.0.6/utils/test_misc.p/src_helpers.c.o
    ninja: build stopped: subcommand failed.
    

    This is easly fixed with that patch:

    diff --git a/examples/parse_eapol/parse_eapol.c b/examples/parse_eapol/parse_eapol.c
    index cf35a6f..f36685b 100644
    --- a/examples/parse_eapol/parse_eapol.c
    +++ b/examples/parse_eapol/parse_eapol.c
    @@ -38,7 +38,7 @@ void handle_pkt(unsigned char *args, const struct pcap_pkthdr *header, const uns
                 printf("EAPOL: Descriptor: %d\n", data.descriptor);
                 printf("EAPOL: Key Info: Information: 0x%04x\n", data.key_info.information);
                 printf("EAPOL: Key Info: Key Length: %d\n", data.key_info.key_length);
    -            printf("EAPOL: Key Info: Replay Counter: %lu\n", data.key_info.replay_counter);
    +            printf("EAPOL: Key Info: Replay Counter: %"PRIu64"\n", data.key_info.replay_counter);
                 printf("EAPOL: Key Info: Nonce: ");
                 for (size_t i = 0; i < sizeof(data.key_info.nonce); ++i) {
                     printf("%02x ", data.key_info.nonce[i]);
    diff --git a/utils/src/test_parsing.c b/utils/src/test_parsing.c
    index b9f9dbc..84a1bde 100644
    --- a/utils/src/test_parsing.c
    +++ b/utils/src/test_parsing.c
    @@ -370,7 +370,7 @@ void parse_data_eapol(struct libwifi_frame frame, unsigned char *args, const str
                 printf("EAPOL: Descriptor: %d\n", data.descriptor);
                 printf("EAPOL: Key Info: Information: 0x%04x\n", data.key_info.information);
                 printf("EAPOL: Key Info: Key Length: %d\n", data.key_info.key_length);
    -            printf("EAPOL: Key Info: Replay Counter: %llu\n", data.key_info.replay_counter);
    +            printf("EAPOL: Key Info: Replay Counter: %"PRIu64"\n", data.key_info.replay_counter);
                 printf("EAPOL: Key Info: Nonce: ");
                 for (size_t i = 0; i < sizeof(data.key_info.nonce); ++i) printf("%02x ", data.key_info.nonce[i]);
    
    

    The second snippet avoids a warning

    opened by solsticedhiver 7
Releases(0.0.7)
  • 0.0.7(Oct 2, 2022)

    Feature / Bugfix Release

    • Fix an issue where Radiotap header generation could produce unaligned fields
    • Fix an issue where the EAPOL example would throw a warning/error due to incorrect format specifier
    • Add support for macOS
    • Automatically produce a statically linkable library during build
    Source code(tar.gz)
    Source code(zip)
  • 0.0.6(Aug 10, 2022)

  • 0.0.5(Mar 7, 2022)

    Bugfix Release

    • Fix an issue where returned value for libwifi_parse_radiotap_info() wasn't checked, potentially leading to a crash
    • Improve memory handling in libwifi_get_wifi_frame() to reduce heap allocations
    Source code(tar.gz)
    Source code(zip)
  • 0.0.4(Mar 7, 2022)

  • 0.0.3(Jan 29, 2022)

    Feature Release

    • Add the ability to specify a different BSSID than the Transmitter in a Beacon Frame
    • Add the ability to specify the Address 3 field for all Management frames
    • Improve the header comments for generation functions
    • Remove the automatic addition of the "Supported Rates" tagged parameter to Beacons and Probe Requests
    • libwifi_get_version() will now print the version specified in CMakeLists.txt, or the Git branch and commit hash if built in Debug mode

    This update breaks the ABI for almost all generation functions, by requiring the address 3 parameter. In most cases, this is desired to be the BSSID/Transmitter.

    Source code(tar.gz)
    Source code(zip)
  • 0.0.2(Jan 13, 2022)

    Bugfix Release

    • Fix libwifi_verify_frame() and clarify usage.
    • Add LIBWIFI_FLAGS_IS_ORDERED flag.
    • Ensure minimum length of frame is checked when parsing an 802.11 frame specified as containing Radiotap.
    • Add TAG_ELEMENT_EXTENSION tagged parameter.
    • Multiple styling fixes and improvements for examples.
    • Removed unused headers.
    • Added frame parser tests.
    • Added some frame generation tests.
    • Remove hard-coded compiler configuration.
    Source code(tar.gz)
    Source code(zip)
  • 0.0.1(Dec 1, 2021)

    Initial Release

    This is the first release of libwifi! It includes a comprehensive set of frame generators (Including all 802.11 Management Frames), a comprehensive set of frame parsers, a fully implemented Tagged Parameter system and Radiotap support. A full list of implemented features at this snapshot is below.

    Features Implemented

    Generation

    • Misc
      • [X] Radiotap Header
      • [X] Random MAC Generation
    • Management
      • [X] Association Request
      • [X] Association Response
      • [X] Reassociation Request
      • [X] Ressociation Response
      • [X] Probe Request
      • [X] Probe Response
      • [X] Timing Advertisement
      • [X] Beacon
      • [X] ATIM
      • [X] Disassociation
      • [X] Deauthentication
      • [X] Action
      • [X] Action No ACK
    • Control
      • [X] RTS (Request-to-Send)
      • [X] CTS (Clear-to-Send)

    Parsing

    • Misc
      • [X] Radiotap Header
    • Management
      • [X] Association Request
      • [X] Association Response
      • [X] Reassociation Request
      • [X] Ressociation Response
      • [X] Probe Request
      • [X] Probe Response
      • [X] Beacon
      • [X] Disassociation
      • [X] Deauthentication
    • Data
      • [X] Data Frame (Basic)
      • [X] QoS Data Frame (Basic)
      • [X] EAPOL
    Source code(tar.gz)
    Source code(zip)
Arduino library for basic aerial navigation functions used for processing Euler angles, direction cosine matrices, quaternions, frame conversions, and more.

navduino Arduino library for basic aerial navigation functions used for Euler angles Direction cosine matrices Quaternions Rodrigues Rotation Vectors

PB2 7 Oct 24, 2022
this is very basic version for our dataset validation, only change the path, and align the frame of vio and Groundtruth

VINS-Fusion for UrbanNavDataset Evaluation 1. Prerequisites please refer to VINS-Fusion Github 2. Build mkdir catkin/src cd catkin/src mkdir result cd

baaixw 13 Sep 5, 2022
Icopack - A simple command line tool to create multi-frame ICO files from PNG source images

Optidash is a modern, AI-powered image optimization and processing API. We will drastically speed-up your websites and save you money on bandwidth and

Optidash AI 61 Jul 27, 2022
The frame work for WhaleMarket C-Beginner Project.

The frame work for WhaleMarket C-Beginner Project.

Cui Jiacai 28 Nov 11, 2022
A procedural geometry generation library for C++11

Generator - A procedural geometry generation library. The purpose of this library is to easily generate procedural meshes of geometric primitives such

Ilmola 155 Oct 14, 2022
A static C++ library for the generation of discrete functions on a box-shaped domain

A static C++ library for the generation of discrete functions on a box-shaped domain. This is especially suited for the discretization of signed distance fields.

Interactive Computer Graphics 234 Oct 26, 2022
A single-header C/C++ library for parsing and evaluation of arithmetic expressions

ceval A C/C++ header for parsing and evaluation of arithmetic expressions. [README file is almost identical to that of the ceval library] Functions ac

e_t 9 Oct 10, 2022
A single-header C/C++ library for parsing and evaluation of arithmetic expressions

ceval A C/C++ header for parsing and evaluation of arithmetic expressions. [README file is almost identical to that of the ceval library] Functions ac

e_t 9 Oct 10, 2022
Just a basic mini library for parsing simple files that only have variables written and with Lua extension.

C++ Parser Lua file config Just a basic mini library for parsing simple files that only have variables written and with Lua extension. Note: At the mo

Marcos Oliveira 3 Dec 26, 2021
ZSV/lib: a fast CSV parsing library and standalone utility

Please note: this code is still alpha / pre-production. Everything here should be considered preliminary. If you like ZSVlib, please give it a star! Z

null 84 Nov 28, 2022
A C/C++ library for parsing and evaluation of arithmetic expressions.

ceval A C/C++ header for parsing and evaluation of arithmetic expressions. Functions accessibe from main() Function Argument(s) Return Value ceval_res

e_t 6 Nov 8, 2022
This project contains a library for C++ AST parsing, metaprogramming and reflection

Meta C++ This project contains a library for C++ AST parsing, metaprogramming and reflection. Also included is a tool for generating the necessary met

Keith Hammond 76 Oct 14, 2022
Parsing Expression Grammar Template Library

Welcome to the PEGTL The Parsing Expression Grammar Template Library (PEGTL) is a zero-dependency C++ header-only parser combinator library for creati

The Art of C++ 1.6k Nov 24, 2022
A lightweight C++14 parsing library for tmx map files created with the Tiled map editor

tmxlite Description A lightweight C++14 parsing library for tmx map files created with the Tiled map editor. Requires no external linking, all depende

Matt Styles 322 Oct 30, 2022
A model checker for the Dynamic Logic of Propositional Assignments (DL-PA) with solving and parameterized random formula generation functionalities.

A model checker for the Dynamic Logic of Propositional Assignments (DL-PA) with solving and parameterized random formula generation functionalities.

Jeffrey Yang 7 Dec 31, 2021
Light probe generation and BRDF authoring for physically based shading.

IBLBaker About IBLBaker is provided under the MIT License(MIT) Copyright(c) 2015 Matt Davidson. Please see the LICENSE file for full details. Feel fre

MattD 657 Nov 16, 2022
Stack-based texture generation tool written in C99!

Stack-based texture generation tool written in C99! Brought to you by @zaklaus and contributors Introduction zpl.texed is a cross-platform stack-based

zpl | pushing the boundaries of simplicity. 19 Sep 10, 2022
FluidNC - The next generation of motion control firmware

FluidNC (CNC Controller) For ESP32 Introduction FluidNC is the next generation of Grbl_ESP32. It has a lot of improvements over Grbl_ESP32 as listed b

null 628 Nov 21, 2022
🎻 Automatic Exploit Generation using symbolic execution

S2E Library This repository contains all the necessary components to build libs2e.so. This shared library is preloaded in QEMU to enable symbolic exec

ᴀᴇꜱᴏᴘʜᴏʀ 29 Jan 10, 2022