community_id/lib.rs
1//! [![github]](https://github.com/traceflight/rs-community-id) [![crates-io]](https://crates.io/crates/community-id)
2//!
3//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
4//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
5//!
6//! <br>
7//!
8//! This package provides a Rust implementation of the open [Community ID](https://github.com/corelight/community-id-spec)
9//! flow hashing standard.
10//!
11//! <br>
12//!
13//! # Community ID
14//!
15//! "Community ID" is a separate specification for generating a likely-unique identifier for a network connection proposed
16//! by Corelight (the company behind Bro/Zeek). See [community-id-spec](https://github.com/corelight/community-id-spec)
17//!
18//! # Usage
19//!
20//! ```
21//! use std::net::Ipv4Addr;
22//! use community_id::calculate_community_id;
23//!
24//! let id = calculate_community_id(
25//! 0,
26//! Ipv4Addr::new(1, 2, 3, 4).into(),
27//! Ipv4Addr::new(5, 6, 7, 8).into(),
28//! Some(1122),
29//! Some(3344),
30//! 6,
31//! Default::default(),
32//! );
33//! assert_eq!("1:wCb3OG7yAFWelaUydu0D+125CLM=", id.unwrap());
34//! ```
35
36mod calc;
37mod icmpv4;
38mod icmpv6;
39mod ipv4;
40mod ipv6;
41
42/// Default Padding
43const PADDING: u8 = 0;
44
45/// IP Protocol Number of ICMP
46const IPPROTO_ICMP: u8 = 1;
47
48/// IP Protocol Number of ICMPv6
49const IPPROTO_ICMPV6: u8 = 58;
50
51/// IP Protocol Number of SCTP
52const IPPROTO_SCTP: u8 = 132;
53
54/// IP Protocol Number of TCP
55const IPPROTO_TCP: u8 = 6;
56
57/// IP Protocol Number of UDP
58const IPPROTO_UDP: u8 = 17;
59
60pub use calc::calculate_community_id;