flow: add accessors for flow addresses

Expose source and destination addresses as raw byte pointers, so FFI
callers do not need the internal FlowAddress layout.
pull/16053/head
Jason Ish 3 months ago committed by Victor Julien
parent f205d181f9
commit bedd65f766

@ -1850,6 +1850,14 @@ extern "C" {
extern "C" {
pub fn SCFlowGetDestinationPort(flow: *const Flow) -> u16;
}
extern "C" {
#[doc = " \\brief Returns a borrowed raw pointer to the flow source address.\n\n The address is in network byte order. Use SCFlowIsIPv4 and SCFlowIsIPV6 to\n properly determine the size and family of the address."]
pub fn SCFlowGetSourceAddressAsRawPtr(flow: *const Flow) -> *const u8;
}
extern "C" {
#[doc = " \\brief Returns a borrowed raw pointer to the flow destination address.\n\n The address is in network byte order. Use SCFlowIsIPv4 and SCFlowIsIPV6 to\n properly determine the size and family of the address."]
pub fn SCFlowGetDestinationAddressAsRawPtr(flow: *const Flow) -> *const u8;
}
extern "C" {
pub fn SCFlowGetToServerPacketCount(flow: *const Flow) -> u32;
}

@ -28,6 +28,22 @@ bool SCFlowIsIPv6(const Flow *flow);
uint8_t SCFlowGetIPProtocol(const Flow *flow);
uint16_t SCFlowGetSourcePort(const Flow *flow);
uint16_t SCFlowGetDestinationPort(const Flow *flow);
/**
* \brief Returns a borrowed raw pointer to the flow source address.
*
* The address is in network byte order. Use SCFlowIsIPv4 and SCFlowIsIPV6 to
* properly determine the size and family of the address.
*/
const uint8_t *SCFlowGetSourceAddressAsRawPtr(const Flow *flow);
/**
* \brief Returns a borrowed raw pointer to the flow destination address.
*
* The address is in network byte order. Use SCFlowIsIPv4 and SCFlowIsIPV6 to
* properly determine the size and family of the address.
*/
const uint8_t *SCFlowGetDestinationAddressAsRawPtr(const Flow *flow);
uint32_t SCFlowGetToServerPacketCount(const Flow *flow);
uint32_t SCFlowGetToClientPacketCount(const Flow *flow);
AppProto SCFlowGetAppProtocol(const Flow *f);

@ -1241,6 +1241,16 @@ uint16_t SCFlowGetSourcePort(const Flow *flow)
return flow->sp;
}
const uint8_t *SCFlowGetSourceAddressAsRawPtr(const Flow *flow)
{
return flow->src.address.address_un_data8;
}
const uint8_t *SCFlowGetDestinationAddressAsRawPtr(const Flow *flow)
{
return flow->dst.address.address_un_data8;
}
/**
* \brief Return true if the flow is IPv4.
*/

Loading…
Cancel
Save