in nfm-controller/src/utils/conntrack_listener.rs [86:130]
fn parse_connection_properties(
msg: NetlinkMessage<NetfilterMessage>,
) -> Result<(ConnectionProperties, ConnectionProperties), String> {
let mut orig_opt: Option<ConnectionProperties> = None;
let mut reply_opt: Option<ConnectionProperties> = None;
if let NetlinkPayload::<NetfilterMessage>::InnerMessage(imsg) = msg.payload {
if let NetfilterMessageInner::NfConntrack(NfConntrackMessage::ConnectionNew(nlas)) =
imsg.inner
{
for nla in nlas {
match nla {
ConnectionNla::TupleOrig(tuple) => {
match ConnectionProperties::try_from(tuple) {
Ok(cxn) => orig_opt = Some(cxn),
Err(e) => {
return Err(format!(
"Failed to extract original connection properties: {:?}",
e
));
}
}
}
ConnectionNla::TupleReply(tuple) => {
match ConnectionProperties::try_from(tuple) {
Ok(cxn) => reply_opt = Some(cxn),
Err(e) => {
return Err(format!(
"Failed to extract reply connection properties: {:?}",
e
));
}
}
}
_ => {}
}
}
}
}
match (orig_opt, reply_opt) {
(Some(orig), Some(reply)) => Ok((orig, reply)),
_ => Err("Connection properties not found".to_string()),
}
}