wifi_lab
Clone
https://git.tahinli.com/Tahinli/wifi_lab.git
0 watching0 forksRust2.1 MiBb265998Tahinli1 month ago27 commits
| 1 | //! libpcap (DLT) capture-file writer for the scan spool and `.pcap` export. |
| 2 | //! |
| 3 | //! File format (all multi-byte header fields little-endian): |
| 4 | //! global header: magic `0xa1b2c3d4`, version 2.4, thiszone 0, sigfigs 0, |
| 5 | //! snaplen 65535, linktype 127 (`DLT_IEEE802_11_RADIO`, radiotap). Each |
| 6 | //! packet record: `ts_sec`/`ts_usec` ([`SystemTime::now`]), |
| 7 | //! `incl_len == orig_len == frame.len()`, then the frame bytes. |
| 8 | |
| 9 | use ; |
| 10 | use ; |
| 11 | use Path; |
| 12 | use ; |
| 13 | |
| 14 | use ; |
| 15 | |
| 16 | /// libpcap little-endian magic (as written byte order: d4 c3 b2 a1). |
| 17 | const MAGIC_LE: u32 = 0xa1b2_c3d4; |
| 18 | const VERSION_MAJOR: u16 = 2; |
| 19 | const VERSION_MINOR: u16 = 4; |
| 20 | const SNAPLEN: u32 = 65535; |
| 21 | /// DLT_IEEE802_11_RADIO: frames carry a radiotap header. |
| 22 | const LINKTYPE_RADIOTAP: u32 = 127; |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | /// Create a new capture file at `path`, truncating any existing content and |
| 40 | /// writing the global header. |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | /// Open `path` so new frames land after existing ones: an existing |
| 49 | /// non-empty file is opened for append WITHOUT rewriting the global header |
| 50 | /// (spool continuity across restarts); a missing or empty file gets the |
| 51 | /// header written, exactly like [`create`]. |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 |