### ZettaBGP Dependencies Source: https://github.com/wladwm/zettabgp/blob/main/examples/README.md This TOML snippet shows the necessary dependencies to include ZettaBGP in your project, enabling the 'full' feature set. ```toml [dependencies] zettabgp = { version = "0.1.4", features = ["full"] } ``` -------------------------------- ### Connect and Exchange BGP Open Messages Source: https://github.com/wladwm/zettabgp/blob/main/README.md This snippet demonstrates how to establish a TCP connection to a BGP neighbor, prepare and send an Open message, and then read and decode the neighbor's Open message. Ensure you have a BGP neighbor running on localhost:179. ```rust use zettabgp::prelude::*; use std::io::{Read,Write}; let mut socket = match std::net::TcpStream::connect("127.0.0.1:179") { Ok(sck) => sck, Err(e) => {eprintln!("Unable to connect to BGP neighbor: {}",e);return;} }; let params=BgpSessionParams::new(64512,180,BgpTransportMode::IPv4,std::net::Ipv4Addr::new(1,1,1,1),vec![BgpCapability::SafiIPv4u].into_iter().collect()); let mut buf = [0 as u8; 32768]; let mut open_my = params.open_message(); let open_sz = open_my.encode_to(¶ms, &mut buf[19..]).unwrap(); let tosend = params.prepare_message_buf(&mut buf, BgpMessageType::Open, open_sz).unwrap(); socket.write_all(&buf[0..tosend]).unwrap();//send my open message socket.read_exact(&mut buf[0..19]).unwrap();//read response message head let messagehead=params.decode_message_head(&buf).unwrap();//decode message head if messagehead.0 == BgpMessageType::Open { socket.read_exact(&mut buf[0..messagehead.1]).unwrap();//read message body let mut bom = BgpOpenMessage::new(); bom.decode_from(¶ms, &buf[0..messagehead.1]).unwrap();//decode received message body eprintln!("BGP Open message received: {:?}", bom); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.