{"id":21857219,"url":"https://github.com/sensorfu/luomu-libpcap","last_synced_at":"2025-04-14T18:32:52.656Z","repository":{"id":41974001,"uuid":"190739155","full_name":"sensorfu/luomu-libpcap","owner":"sensorfu","description":"Safe and mostly sane Rust bindings for libpcap","archived":false,"fork":false,"pushed_at":"2023-12-19T13:28:23.000Z","size":4583,"stargazers_count":3,"open_issues_count":3,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2023-12-19T16:11:37.566Z","etag":null,"topics":["hacktoberfest","libpcap","network","rust","rust-bindings"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sensorfu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-06-07T12:22:48.000Z","updated_at":"2023-12-28T09:30:52.953Z","dependencies_parsed_at":"2023-12-19T16:20:05.083Z","dependency_job_id":null,"html_url":"https://github.com/sensorfu/luomu-libpcap","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensorfu%2Fluomu-libpcap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensorfu%2Fluomu-libpcap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensorfu%2Fluomu-libpcap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensorfu%2Fluomu-libpcap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sensorfu","download_url":"https://codeload.github.com/sensorfu/luomu-libpcap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248936660,"owners_count":21186075,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","libpcap","network","rust","rust-bindings"],"created_at":"2024-11-28T02:26:17.900Z","updated_at":"2025-04-14T18:32:52.633Z","avatar_url":"https://github.com/sensorfu.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# luomu-libpcap\n\nSafe and mostly sane Rust bindings for [libpcap](https://www.tcpdump.org/) and\nsome other network related functionalities.\n\n## Lipcap bindings\n\nLibpacp bindings are split in two different crates:\n\n- `luomu-libpcap-sys` for unsafe Rust bindings generated directly from\n  `libpcap`.\n- `luomu-libpcap` for safe and sane libpcap interface.\n\n`luomu-libpcap` crate is split into two parts itself:\n\n- `functions` module contains safe wrappers and sane return values for libpcap\n  functions.\n- the root of the project contains `Pcap` struct et al. for more Rusty API to\n  interact with libpcap.\n\n### Example\n\n```rust\nuse luomu_libpcap::{Pcap, Result};\n\nfn main() -\u003e Result\u003c()\u003e {\n    let pcap = Pcap::builder(\"en0\")?\n        .set_promiscuous(true)?\n        .set_immediate(true)?\n        .set_snaplen(65535)?\n        .set_buffer_size(512 * 1024)?\n        .activate()?;\n\n    pcap.set_filter(\"udp\")?;\n\n    for packet in pcap.capture() {\n        let mut hex = String::new();\n        for i in 0..packet.len() {\n            if i % 4 == 0 {\n                hex.push(' ');\n            }\n            if i % 32 == 0 {\n                hex.push('\\n');\n            }\n            hex.push_str(\u0026format!(\"{:02x}\", packet[i]));\n        }\n        println!(\"{}\", hex);\n    }\n\n    Ok(())\n}\n```\n\n## Other crates\n\nOther crates, these do not require or use `libpcap`:\n\n- `luomu-tpacketv3` contains Rust bindings for capturing network traffic on\n  Linux with `AF_PACKET` sockets and\n  [tpcacket_v3](https://www.kernel.org/doc/Documentation/networking/packet_mmap.txt)\n- `luomu-getifaddrs` provides Rust bindings for `getiffaddrs()` to get network\n  interface addresses and statistics with\n- `luomu-common` contains utilities for working with IP Addresses, MAC addresses\n  and such.\n\nYou probably want to use the `Pcap` struct and other things from root of this\ncrate.\n\n## License\n\nSee [LICENSE](LICENSE). MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsensorfu%2Fluomu-libpcap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsensorfu%2Fluomu-libpcap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsensorfu%2Fluomu-libpcap/lists"}