Skip to content

Commit 268ecb9

Browse files
committed
First release
1 parent 1685169 commit 268ecb9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+6983
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ Cargo.lock
88

99
# These are backup files generated by rustfmt
1010
**/*.rs.bk
11+
**/*.bak

Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "zettabgp"
3+
version = "0.1.0"
4+
authors = ["Vladimir Melnikov <wlad.w.m@gmail.com>"]
5+
edition = "2018"
6+
license = "MIT OR Apache-2.0"
7+
repository = "https://github.com/wladwm/zettabgp"
8+
keywords = ["BGP"]
9+
categories = ["networking"]
10+
description = "This is a BGP (parsing and composing) and BMP (only parsing) protocols driver library for Rust"
11+
readme = "README.md"
12+
13+
[features]
14+
default = ["serialization"]
15+
serialization = ["serde"]
16+
17+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
18+
19+
[dependencies]
20+
serde = { version="1.0.125", optional = true }
21+

README.md

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,92 @@
1-
# zettabgp
2-
BGP &amp; BMP Rust library
1+
zettabgp - BGP&BMP Rust library
2+
====================
3+
4+
This is a BGP and BMP protocols driver library for Rust.
5+
6+
BGP - Border Gateway Protocol version 4.
7+
BMP - BGP Monitoring Protocol version 3.
8+
9+
## Supported BGP message types
10+
Open
11+
Notification
12+
Keepalive
13+
Update
14+
15+
## Supported BMP message types
16+
Initiation
17+
Termination
18+
PeerUpNotification
19+
RouteMonitoring
20+
21+
## Supported address families NLRI (network layer reachability information)
22+
ipv4 unicast
23+
ipv4 labeled-unicast
24+
ipv4 multicast
25+
ipv4 mvpn
26+
vpnv4 unicast
27+
vpnv4 multicast
28+
ipv6 unicast
29+
ipv6 labeled-unicast
30+
ipv6 multicast
31+
vpnv6 unicast
32+
vpnv6 multicast
33+
vpls
34+
evpn
35+
flowspec ipv4
36+
flowspec ipv6
37+
38+
## Supported path attributes
39+
MED
40+
Origin
41+
Local preference
42+
AS path
43+
Communities
44+
Extended communities
45+
Aggregator AS
46+
Atomic aggregate
47+
Cluster list
48+
Originator ID
49+
Attribute set
50+
some PMSI tunnels
51+
52+
## Usage
53+
54+
Library allow you to parse protocol messages (as binary buffers) into Rust data structures to frther processing.
55+
Or generate valid protocol messages from Rust data structure.
56+
So it can be use in any environment (synrchronous or asynchronous) to make a BGP RR, monitoring system or BGP analytics.
57+
58+
```rust
59+
use zettabgp::prelude::*;
60+
use std::io::{Read,Write};
61+
let mut socket = match std::net::TcpStream::connect("127.0.0.1:179") {
62+
Ok(sck) => sck,
63+
Err(e) => {eprintln!("Unable to connect to BGP neighbor: {}",e);return;}
64+
};
65+
let params=BgpSessionParams::new(64512,180,BgpTransportMode::IPv4,std::net::Ipv4Addr::new(1,1,1,1),vec![BgpCapability::SafiIPv4u].into_iter().collect());
66+
let mut buf = [0 as u8; 32768];
67+
let mut open_my = params.open_message();
68+
let open_sz = open_my.encode_to(&params, &mut buf[19..]).unwrap();
69+
let tosend = params.prepare_message_buf(&mut buf, BgpMessageType::Open, open_sz).unwrap();
70+
socket.write_all(&buf[0..tosend]).unwrap();//send my open message
71+
socket.read_exact(&mut buf[0..19]).unwrap();//read response message head
72+
let messagehead=params.decode_message_head(&buf).unwrap();//decode message head
73+
if messagehead.0 == BgpMessageType::Open {
74+
socket.read_exact(&mut buf[0..messagehead.1]).unwrap();//read message body
75+
let mut bom = BgpOpenMessage::new();
76+
bom.decode_from(&params, &buf[0..messagehead.1]).unwrap();//decode received message body
77+
eprintln!("BGP Open message received: {:?}", bom);
78+
}
79+
```
80+
81+
82+
## Crates.io
83+
84+
https://crates.io/crates/zettabgp
85+
86+
## Documentation
87+
88+
https://docs.rs/zettabgp
89+
90+
## License
91+
92+
[MIT OR Apache-2.0](LICENSE)

0 commit comments

Comments
 (0)