Skip to content

Commit

Permalink
Pull request #61: api: Add DIOCTL_GET_PRIV_DATA_LEN ioctl to get priv…
Browse files Browse the repository at this point in the history
…ate data length.

Merge in SNORT/libdaq from ~STECHEW/libdaq:daq_privptr_len_ioctl to master

Squashed commit of the following:

commit 1f73dfc2cebf64340fe9762e1422d077c17d422d
Author: Steve Chew <stechew@cisco.com>
Date:   Thu Jun 15 13:13:29 2023 -0400

    trace: Don't log message when DIOCTL_PRIV_DATA_LEN ioctl is seen.

commit 490ccea2a779cb252f66b870315eab66d95f64dc
Author: Steve Chew <stechew@cisco.com>
Date:   Mon Jun 12 00:25:40 2023 -0400

    api: Add daq_msg_get_priv_data to get pointer to private data.

commit 56535b294c75af3822c75b8fb1f73b54f86a20f8
Author: Steve Chew <stechew@cisco.com>
Date:   Sun Jun 11 23:55:07 2023 -0400

    api: Add DIOCTL_GET_PRIV_DATA_LEN ioctl to get private data length.
  • Loading branch information
stechew committed Jun 16, 2023
1 parent cbad742 commit b3f3c2c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions api/daq.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ static inline int daq_napt_info_dst_addr_family(const DAQ_NAPTInfo_t *napti)
return (napti->flags & DAQ_NAPT_INFO_FLAG_DIP_V6) ? AF_INET6 : AF_INET;
}

static inline const void *daq_msg_get_priv_data(DAQ_Msg_h msg)
{
return msg->priv;
}

#ifdef __cplusplus
}
#endif
Expand Down
14 changes: 13 additions & 1 deletion api/daq_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern "C" {
#include <unistd.h>

// Comprehensive version number covering all elements of this header
#define DAQ_COMMON_API_VERSION 0x00030004
#define DAQ_COMMON_API_VERSION 0x00030005

#ifndef DAQ_SO_PUBLIC
# ifdef HAVE_VISIBILITY
Expand Down Expand Up @@ -411,6 +411,7 @@ typedef enum
DIOCTL_CREATE_EXPECTED_FLOW,
DIOCTL_DIRECT_INJECT_PAYLOAD,
DIOCTL_DIRECT_INJECT_RESET,
DIOCTL_GET_PRIV_DATA_LEN,
LAST_BUILTIN_DIOCTL_CMD = 1024, /* End of reserved space for "official" DAQ ioctl commands.
Any externally defined ioctl commands should be larger than this. */
MAX_DIOCTL_CMD = UINT16_MAX
Expand Down Expand Up @@ -616,6 +617,17 @@ typedef struct
uint8_t direction; // [in] Direction in which to inject the reset relative to the message (DAQ_DIR_*)
} DIOCTL_DirectInjectReset;

/*
* Command: DIOCTL_GET_PRIV_DATA_LEN
* Description: Get length of private data.
* Argument: DIOCTL_GetPrivDataLen
*/
typedef struct
{
DAQ_Msg_h msg; // [in] Message from which to get priv data length.
uint16_t priv_data_len; // [out] Length of priv data.
} DIOCTL_GetPrivDataLen;

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions modules/trace/daq_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ static int trace_daq_ioctl(void *handle, DAQ_IoctlCmd cmd, void *arg, size_t arg
fprintf(tc->outfile, "\n");
break;
}
case DIOCTL_GET_PRIV_DATA_LEN:
{
break;
}

default:
fprintf(tc->outfile, "IOCTL: %d (%zu)\n", cmd, arglen);
Expand Down

0 comments on commit b3f3c2c

Please sign in to comment.